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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,351
Office Version
  1. 365
Platform
  1. Windows
Try this.
Code:
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("A11:A" & LastRow).Select
 

Datsmart

Well-known Member
Joined
Jun 19, 2003
Messages
7,985
This will Select the range you want:
Code:
EndRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A11:A" & EndRow).Select
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Try:

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

Forum statistics

Threads
1,170,932
Messages
5,872,776
Members
432,944
Latest member
mj02

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
Top