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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rows(xx:xx).Select statement

Status
Not open for further replies.

miche7

Programmer
Jan 14, 2003
12
0
0
US
I have a macro which runs from a button on worksheet "Index" to hide unused rows on other sheets in the same workbook. The code I need assistance with:

' Rows("BeginUnused:EndUnused").Select
‘ This code works
Rows("5:99").Select
Selection.EntireRow.Hidden = True

"BeginUnused" in cell Index!C12 and "EndUnused" in cell Index!D12 are variables. If "BeginUnused" should change to 46, for example, I currently have to manually edit the macro. How do I use cell references in the Rows(xx:xx).Select statement?

Any assistance is greatly appreciated.

Michele
 
range(cells(range("BeginUnused"),1),cells(range("EndUnused"),1).entirerow.hidden=true

will do the trick. This assumes that the sheet on which the rows to be hidden reside is active, and that you have named ranges to refer to the cells on Index. If they are not named ranges but variables, use:

range(cells(BeginUnused,1),cells(EndUnused,1).entirerow.hidden=true

Rob
[flowerface]
 
Or
Rows(sheets("Index").range("C12").value & ":" & sheets("Index").range("D12").value).entirerow.hidden = true

or

BeginUsed = sheets("Index").range("C12").value
EndUsed = sheets("Index").range("D12").value

Activesheet.rows(BeginUsed & ":" & EndUsed).entirerow.hidden = true Rgds
Geoff

Si hoc legere scis, nimis eruditionis habes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top