Stuck with: Range(Selection, Selection.End(xlDown)).Select

sneel3

Active Member
Joined
Oct 9, 2002
Messages
334
My vba looks something like this:

Range("A11").Select
Range(Selection, Selection.End(xlDown)).Select

This works great as long as there are 2 or more rows; however, sometimes there is only 1 row. When this happens, the range extends to the bottom of the spreadsheet.

How do I make the vba say:

If row 11 is the only row (after row 10) that is populated, only select A11, otherwise
Range("A11").Select
Range(Selection, Selection.End(xlDown)).Select
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try this.
Code:
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("A11:A" & LastRow).Select
 
Upvote 0
This will Select the range you want:
Code:
EndRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A11:A" & EndRow).Select
 
Upvote 0
Try:

Code:
Range("A11").Select
If Not IsEmpty(Selection.Offset(1, 0)) Then
    Range(Selection, Selection.End(xlDown)).Select
End If
 
Upvote 0

Forum statistics

Threads
1,214,659
Messages
6,120,781
Members
448,992
Latest member
prabhuk279

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