Hello,
I have written a code on VBA to have a button which shows/hides cells based on specific column addresses. Unfortunately, I think this is not the ideal way, since if someone adds a row, the entire code will have to be re-written. Is there any way to have this done either through loops, or by using named ranges? I would really appreciate if someone could show me how to do it. This is a sample of my code:
Sub ShowHideSemesterBudgets()
Dim S1Budget As String
Dim S2Budget As String
S1Budget = "F"
S2Budget = "AZ"
If Columns(S1Budget).EntireColumn.Hidden = False Then
Columns(S1Budget).EntireColumn.Hidden = True
Else
Columns(S1Budget).EntireColumn.Hidden = False
End If
If Columns(S2Budget).EntireColumn.Hidden = False Then
Columns(S2Budget).EntireColumn.Hidden = True
Else
Columns(S2Budget).EntireColumn.Hidden = False
End If
End Sub
Thanks a bunch!
Best,
Will
Bookmarks