Forum Discussion
Chan_Tze_Leong
Mar 28, 2022Brass Contributor
View selected columns in Excel using VBA
I am considering of viewing the Q1 (Jan to Mar), Q2 (Jan to June), Q3 (Jan to Sep) and Q4 (Jan tro Dec) ufor Target and Actual months using VBA. The below does not work. Please advise Cells.Select...
Chan_Tze_Leong
Mar 29, 2022Brass Contributor
Hi! Could you please share the VBA code?
NikolinoDE
Mar 29, 2022Gold Contributor
Here is the VBA code, you just have to create a new button for each month and show/hide the columns accordingly.
Option Explicit
Private Sub CommandButton1_Click() ' To Show ONLY your Janaury Columns
'Me.Unprotect ("yourpass")
Application.ScreenUpdating = False
With ActiveSheet
.Range("E:AS").EntireColumn.Hidden = True ' Displays the month of January ONLY
.Range("F:F, S:S").EntireColumn.Hidden = False 'Always Unhides All your Columns from your previous action
End With
Application.ScreenUpdating = True
'Me.Protect ("yourpass")
End Sub
Hope I was able to help you with this information.
I know I don't know anything (Socrates)