Selection.end issue

ekslit

New Member
Joined
Apr 10, 2020
Messages
48
Hello guys,

I have a problem with selection.end. Let me share a piece of the code

VBA Code:
     Dim cell As Range
     Dim sourceRange As Range   
     Set sourceRange = Range(wsJiraReport.Range("A2"), Selection.End(xlDown))
      For Each cell In sourceRange
            MyRelease = Application.Match(wsJiraReport.Range("A" & cell.Row), MatchFind, 0)
            If IsError(MyRelease) Then
                wsJiraReport.Range("B" & cell.Row).Value = "N/A"
            Else
            wsJiraReport.Range("B" & cell.Row).Value = Application.WorksheetFunction.Index(IndexPrint, MyRelease)
            End If
        Next

SourceRange is from A2 to A120 but i m getting N/A printed in all rows below B120 qnd then Excel stop responding. Seems like it's unlimited loop.

How can i be sure that Selection.End(xlDown) is 120 and not unlimited? Do you see any issue with the code above?

Thanks for the help.
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Maybe this?
VBA Code:
Set sourceRange = Range(wsJiraReport.Range("A2"), wsJiraReport.Range("A2").End(xlDown))
 
Upvote 0
You are welcome.

By using Selection, that uses whatever cell is selected when the VBA code starts running.
You want it to start from a specific place, so you want to use that place instead of "Selection".
 
Upvote 0
Now that you have pointed the issue. Seems logical ;)
Thanks again for sharing with us your knowledge and expertise.
 
Upvote 0
No problem!
Happy to help!
:)
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,310
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top