Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Row Range using a variable 1

Status
Not open for further replies.

accjrf

Technical User
Apr 1, 2004
39
US
This is probably easy but i just cant seem to write this correctly. I am trying to select a range of rows in Excel but i want to select it by using a variable.

Standard way:
Rows("2:12").EntireRow.Select

What I want to do:
Where IntStartRow = 2 & IntEndRow = 12

Rows( ? IntStartRow : IntEndRow ?).EntireRow.Select
 

hi,

The SHORT answer is...
Code:
dim lStartRow as long, lEndRow as long

with SomeSheetObject
   range(.cells(lStartRow,1), .cells(lEndRow,1)).entirerow.select 
end with
LONG answer starts with question

WHAT are you trying to do, not HOW do you think it need to be done. You obviously are not planning to stop after selecting these row, so what's the objective?


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Unhiding rows that were previously hidden the last time the report was saved, sorting on a given column, and then hiding rows that have a value under $x.

I just didnt want to "hard-code" in a range of rows because the report may grow or shrink so i am doing a Find and then getting the value of a start row position and an end row position and then selecting everything in between.

I think i have the rest figured out...just couldnt think how to do a range with variables...

Thanks for the quick response!
 


hiding rows that have a value under $x.
Check out the AutoFilter. You can record a macro setting it then just run the macro. SIMPLE!

Same with CLEARING the filter!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top