View Full Version : Solved: hiding Rows using index number
Salvo
11-15-2009, 03:04 PM
Using VBA I am trying to reference a cluster of rows to hide in an excel spreadsheet using indexes. Because the rows are variable I can not use a statement such as rows("4:12").hide which only references fixed rows. I can hide each row individually but i find this takes a long time as there are numerous rows to delete (even with screen updating turned off) and the row locations are variable.
Can anyone suggest a way to achieve my aim.
Many thanks
Bob Phillips
11-15-2009, 03:13 PM
Rows(myVar).Resize(12).Hidden = True
mdmackillop
11-16-2009, 01:53 AM
Turning Bob's code into a routine to which you can easily refer
Sub test()
Call HideRows(4, 12)
End Sub
Sub HideRows(Strt As Long, Rws As Long)
Rows(Strt).Resize(Rws).Hidden = True
End Sub
Bob Phillips
11-16-2009, 03:39 AM
Turning Bob's code into a routine to which you can easily refer
Sub test()
Call HideRows(4, 12)
End Sub
Sub HideRows(Strt As Long, Rws As Long)
Rows(Strt).Resize(Rws).Hidden = True
End Sub
Maybe it would be best to make the visibility parameterised as well
Sub test()
Call HideRows(4, 12, True)
End Sub
Sub HideRows(Strt As Long, Rws As Long, state As Boolean)
Rows(Strt).Resize(Rws).Hidden = state
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.