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.
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,457
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,762
Messages
5,574,091
Members
412,567
Latest member
mm1
Top