How to select rows with a variable with VBA?

unit213

Active Member
Joined
Jul 11, 2003
Messages
427
What's the proper VBA syntax for selecting rows when a variable
is involved?

Rows("Endrow:2000").Select sure doesn't seem to work.

In my worksheet, "endrow" is row 830. I want to select all rows
in between 830 and 2000 then delete them.

endrow = Range("A65536").End(xlUp).Row

Thanks in advance.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
63,303
Office Version
  1. 365
Platform
  1. Windows
Rows(Range("A65536").End(xlUp).Row & ":2000").Select
or
Rows(EndRow & ":2000").Select
if you have already calculated the end row
(EndRow is a variable, so don't use quotes around it. Using quotes denotes a literal text value).
 

unit213

Active Member
Joined
Jul 11, 2003
Messages
427
Thanks alot. I wasted 45mins trying to figure that out and trying
to hunt down the solution via the search function here. Sometimes
it's best just to ask.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,022
Messages
5,834,994
Members
430,330
Latest member
Syed Yasir Hannan

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