Hello All,
I would like some help on VBA code for hiding certain columns based off of a cell reference. This question has been solved here, but I now want to connect the macro to a button as seen here. The cell to be referenced is in row 3, (in columns B case, B3) and is a conditional IF statement based on another sheet in the workbook. The possible results are 0 and "".
The First Button Labaled Relevant Data (this is the button I want to be able to click and have it hide coloumns which the third row is equal to 0). This is the one I need help on. I currently have
Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim Target As Range
Set Target = Range("B3:BA3")
If Target.Count > 1 Then Exit Sub
If Union(Range("$B$3:$BA$3"), Target).Address = Range("$B$3:$BA$3").Address Then
If Target.Value = 0 Then Target.EntireColumn.Hidden = True
End If
Application.ScreenUpdating = True
End Sub
'
The Second button is labaled "Show all Cells". This button Works, and I do not need help with it, but the code is displayed below
Sub CommandButton2_Click()
Application.ScreenUpdating = False
Range("B3:BA3").EntireColumn.Hidden = False
Application.ScreenUpdating = True
End Sub
'
Thank you in advance!
Bookmarks