Hide rows using VBA
Private Sub Workbook_Open()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long
With ActiveSheet
iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow 'iLastRow to 1 Step -1
.Rows(i).Hidden = (.Cells(i, TEST_COLUMN).Offset(0, 2).Value =
"HIDE")
Next i
End With
End Sub
'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
--
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)
"buzzandbeyond" wrote in message
ups.com...
Hi,
I am trying to hide rows with a specific value.
In my sheet I have three columns:
Date - The manually inputted date
Today - 1 Month - 'TODAY() -31' (this column will be hidden)
In Range? - an IF statement to say "HIDE" or SHOW" (this column will
be hidden)
I am looking to hide all the rows where Hide shows in the In Range?
column. I would also like this to run on opening the document
Any advice is gratefully received as my vba skills are almost non
existent.
cheers
Dave
|