Hi all!
I have a macro that hides columns depending on what is in cell "A3", now i need to add another criteria depending on cell "D1" - have built both macros but running the second macro will open some columns that should be closed by the first macro... SO... I need to combine these two macros so columns meeting either criteria will remain closed.
MACRO 1:
Sub hide_columns1()
lngCol = Cells(11, Columns.Count).End(xlToLeft).Column
Application.ScreenUpdating = False
Cells.Columns.Hidden = False
For Each c In Range("F11", Cells(11, lngCol))
MACRO 2:
Sub hide_columns2()
Dim lngCol As Long, c As Range
lngCol = Cells(16, Columns.Count).End(xlToLeft).Column
Application.ScreenUpdating = False
Cells.Columns.Hidden = False
For Each c In Range("F16", Cells(16, lngCol))
I have a macro that hides columns depending on what is in cell "A3", now i need to add another criteria depending on cell "D1" - have built both macros but running the second macro will open some columns that should be closed by the first macro... SO... I need to combine these two macros so columns meeting either criteria will remain closed.
MACRO 1:
Sub hide_columns1()
Dim lngCol As Long, c As Range
lngCol = Cells(11, Columns.Count).End(xlToLeft).Column
Application.ScreenUpdating = False
Cells.Columns.Hidden = False
For Each c In Range("F11", Cells(11, lngCol))
c.EntireColumn.Hidden = c.Value <> Range("A3").Value
Next c
Application.ScreenUpdating = True
End SubApplication.ScreenUpdating = True
Sub hide_columns2()
Dim lngCol As Long, c As Range
lngCol = Cells(16, Columns.Count).End(xlToLeft).Column
Application.ScreenUpdating = False
Cells.Columns.Hidden = False
For Each c In Range("F16", Cells(16, lngCol))
c.EntireColumn.Hidden = c.Value <> Range("D1").Value
Next c
Application.ScreenUpdating = True
End SubApplication.ScreenUpdating = True