Limit range of xldown?

JimS63

New Member
Joined
Dec 8, 2020
Messages
21
Office Version
  1. 365
Platform
  1. Windows
I am using the following code to select the range from the cell below the current cell down to the last cell with data.

VBA Code:
Range(ActiveCell.Offset(1), ActiveCell.End(xlDown).Offset(1)).Select

I want the range to end at row 35 of the current column even if there is data in row 36.

Can anyone help me limit the range so that ActiveCell.End(xlDown) cannot be higher than cell 35?

Thanks in advance.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
This is the best I came up with, have a try:
VBA Code:
Option Explicit
Sub SelectRows()
    Dim LastRow
    LastRow = ActiveCell.End(xlDown).Offset.Row
    If LastRow > 35 Then LastRow = 35
    Range(ActiveCell.Offset(1), Cells(LastRow, ActiveCell.Column)).Select
End Sub
 
Upvote 0
Thanks for the positive feedback(y), glad having been of some help.
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,005
Members
449,203
Latest member
Daymo66

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