New to VBA and need help.
I am trying to hide columns based on a condition. My workbook has
numerous worksheets. Each worksheet contains data for a specific
"account" and each column within the "account" worksheet has month end
data. Therefore row 1 of each worksheet contains month-end values and
each row below has various data for that specific "account."
Furthermore, the first worksheet, which basically serves as a "menu",
has a cell with a specific date. What I would like to do is write a
macro in each worksheet representing an "account" that hides all
columns in the "account" worksheets that have not occurred yet. (i.e.
If the date on the menu worksheet is 3/31/05, I would like all columns
that have month-end values exceeding 3/31/05 to be hidden). Any
suggestions?
For Each sh In Activeworkbook.Worksheets
With sh
If sh.Name <> "Menu" Then
For i = 1 To sh.Cells(1,sh.Columns.Count).End(xlUp).Column
If sh.Cells(1,i).Value >
Worksheets("Menu").Range("A1").Value Then
Columns(i).Hidden = True
End If
Next i
End If
End With
Next sh
where A1 on Menu is the menu date comparing against
--
HTH
Bob Phillips
(replace xxxx in the email address with gmail if mailing direct)
> New to VBA and need help.
>
[quoted text clipped - 10 lines]
> that have month-end values exceeding 3/31/05 to be hidden). Any
> suggestions?
Skornia115 - 05 Jul 2006 23:30 GMT
Forgive my for my ignorance but where do I place this syntax?
> For Each sh In Activeworkbook.Worksheets
> With sh
[quoted text clipped - 33 lines]
> > that have month-end values exceeding 3/31/05 to be hidden). Any
> > suggestions?
Skornia115 - 05 Jul 2006 23:30 GMT
Forgive my for my ignorance but where do I place this syntax?
> For Each sh In Activeworkbook.Worksheets
> With sh
[quoted text clipped - 33 lines]
> > that have month-end values exceeding 3/31/05 to be hidden). Any
> > suggestions?