Hi All
I currently have a worksheet with two command buttons by pressing one it hides all columns in a range that are blank, the other unhides all columns in that range. Is there a way to combine the two so i can use just one button "Hide/Unhide"?
This is the code i have to hide columns:
This is the code i have to unhide columns:
Thanks in Advance
Tom
I currently have a worksheet with two command buttons by pressing one it hides all columns in a range that are blank, the other unhides all columns in that range. Is there a way to combine the two so i can use just one button "Hide/Unhide"?
This is the code i have to hide columns:
Code:
Dim ws As Worksheet Dim rng As Range
Application.ScreenUpdating = False
Sheet12.Unprotect ("passwordhere")
Set ws = Sheet12
For Each rng In ws.Range("D7:BB7")
If rng.Value = "" Then
rng.EntireColumn.Hidden = True
End If
Next rng
Sheet12.Shapes("CommandButton1").Visible = False
Sheet12.Shapes("CommandButton2").Visible = True
Sheet12.Protect ("passwordhere")
This is the code i have to unhide columns:
Code:
Sheet12.Unprotect ("passwordhere")
Sheet12.Columns("D:BB").Hidden = False
Sheet12.Shapes("CommandButton1").Visible = True
Sheet12.Shapes("CommandButton2").Visible = False
Sheet12.Protect ("passwordhere")
Thanks in Advance
Tom