ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable upper and Lower row selection (https://www.excelbanter.com/excel-programming/373508-variable-upper-lower-row-selection.html)

Bythsx-Addagio[_2_]

Variable upper and Lower row selection
 
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.



Tom Ogilvy

Variable upper and Lower row selection
 
rows(X & ":" & Y).Select

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

--
Regards,
Tom Ogilvy


"Bythsx-Addagio" wrote:

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.



Ronald Dodge

Variable upper and Lower row selection
 
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

--
Ronald R. Dodge, Jr.
Production Statistician/Programmer
Master MOUS 2000

"Bythsx-Addagio" wrote in message
...
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.






All times are GMT +1. The time now is 01:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com