MrExcel Consulting
Your One Stop for Excel Tips & Solutions

Select rows using variables


Posted by Darin Wilmert on October 14, 2001 10:06 AM

Hi, I have a need in a macro to select a bunch of rows.
I know you can do something like thi:
Rows("1:5").Select

but I want to use variables instead, like this:
Rows("Beginning:Ending").Select

However, I can't get this to work. Is there any way
to accomplish this? I've tried every permeutation I can
think of, with or without quotes, everything. It won't
accept it with variables. Thanks.

Posted by Shawn on October 14, 2001 1:24 PM

var1 = 1
var2 = 5
Rows(var1 & ":" & var2).Select

That worked for me, looks like you just have to keep the varibles outside the quotes and add the and statement (&)

-Shawn

Where