Hi All,
I am trying to write a code where I can hide all columns that contains "0" in a specific cell in each column. The values are linked to another sheet and they are dynamic as they will change as new data arrives. I have managed to do this bit but some of the cells which previously were "0" are bound to change and hence I will no longer want them to be hidden anymore.
So I tried to embed an extra line of code which commands to unhide all columns and then run the above mentioned code so that everything will be refreshed. My code does not seem to work though; probably because I am not ending the first command properly and telling VBA to run the next code or it just loops the first one. It must be something very simple, however, I am not certain at all.
Below is the code I have tried and failed with.
Any help will be much appreciated.
Many thanks in advance!
Sub Refresh_Distribution()
Dim p As Range
For Each p In Range("A15:AM15").Cells
If p.Value = "0" Then
p.EntireColumn.Hidden = True
End If
Next p
End Sub
Sub Unhide_and_Hide_Relevant_Columns()
Columns.EntireColumn.Hidden = False
Refresh_Portfolio_Distribution "this one is the name of the first code"
MsgBox "Fund Distibution Table is refreshed."
End Sub
Bookmarks