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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
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).
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,666
Members
448,977
Latest member
moonlight6

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