Variable upper and Lower row selection

G

Guest

Hello all,

I have the following
Rows("1:" & x).Select

But now I am trying to find the syntax for selecting rows based on two
variables.

ie.
x= upper_limit
y=lower_limit

Rows(x:y).Select

this gives me an error: Expected list seperator or )

Help please.
 
G

Guest

rows(X & ":" & Y).Select

make sure there is a space between the variable and the ampersand.
 
R

Ronald Dodge

It would be something like:

Workbooks("Book1.xls").Worksheets("Sheet1").Range(CStr(x) & ":" &
CStr(y)).Select

The Rows object is actually a collection object, thus the argument within
the paranthesis is expecting a numeric value from 1 to the number of rows
within that collection, such as if x is 4 and y is 9, then the Rows
collection object would have a total of 6 different Row objects within it as
indicated by the Count property on the Rows collection object:

Workbooks("Book1.xls").Worksheets("Sheet1").Range(CStr(x) & ":" &
CStr(y)).Rows.Count
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top