MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Using variables to select a range


Posted by Ken on August 15, 2001 2:43 PM

I have a macro that finds two columns, a start date and an end date, on the same sheet. I used variable names for each of the two columns. I want to select these two columns and all columns between these two columns. My variables receive the correct value for their respective columns. I can't get the syntax correct to identify the Range. Here is my last attempt:

Worksheets("Payroll").Range(startColumn & stopColumn).Select

The variables are startColumn and stopColumn. Each will select the correct column, when tested separately.


Posted by Russell Hauf on August 15, 2001 4:20 PM

Try this:

Worksheets("Payroll").Range(columns(startColumn), columns(stopColumn)).Select

Hope this helps,

Russell

Posted by Ken on August 16, 2001 7:40 AM


Thanks, it works very well.