Range(Selection, Selection.End(xlUp)).Select to stop at row 2 and not include header rows.

bensko

Board Regular
Joined
Mar 4, 2008
Messages
173
I'm sure there is a simple solution to this, but I am having trouble finding the right one.

Any way to have Range(Selection, Selection.End(xlUp)).Select stop at row 3 and disregard the two header rows.

Something like Range(Selection, Selection.End(xlUp)-2).Select

Thanks in advance,

Ben
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi,
I would just stop and check:

Code:
Range(Selection, Selection.End(xlUp)).Select
If Selection.Row < 3 Then
    Cells(3, Selection.Column).Select
End If

ξ
 
Upvote 0
Note, or better (to preserve selection size):

Code:
Range(Selection, Selection.End(xlUp)).Select
If Selection.Row < 3 Then
    Selection.Offset(3 - Selection.Row, ).Select
End If

Test first - I may have the syntax wrong.
 
Upvote 0
I did have the syntax wrong, and I think we want to resize the selection as well, so, try again:

Code:
Sub foo()

Range(Selection, Selection.End(xlUp)).Select
If Selection.Row < 3 Then
    Selection.Offset(3 - Selection.Row).Resize( _
        Selection.Rows.Count - (3 - Selection.Row), Selection.Columns.Count) _
        .Select
End If


End Sub
 
Upvote 0
Sorry for my delayed appreciation - thank you!! This is exactly what I was looking for.

I did have the syntax wrong, and I think we want to resize the selection as well, so, try again:

Code:
Sub foo()

Range(Selection, Selection.End(xlUp)).Select
If Selection.Row < 3 Then
    Selection.Offset(3 - Selection.Row).Resize( _
        Selection.Rows.Count - (3 - Selection.Row), Selection.Columns.Count) _
        .Select
End If


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,181
Members
449,071
Latest member
cdnMech

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