Hide columns

Hello,

Please help with my problem.

I’m green on this. Newer tried to code…

In sheet1 I need to show all columns from (C:N), where is selected month in (B2), other columns must hide. If i chose month 4 in B2, then i need to see only these columns where is date with month 4 in (C:N) and etc.

If i have full calendar of dates, how to find exact month and hide others??

table1

Private Sub Worksheet_Change(ByVal Target As Range)
Dim wb As Workbook
Dim ws As Worksheet
Dim entireRange As Range
Set wb = ThisWorkbook
Set ws = wb.Sheets("Sheet1")
Set entireRange = ws.Columns("C:N")

entireRange.EntireColumn.Hidden = False

Select Case ws.Range("B2")

  Case "1"
      ws.Range("G:N").EntireColumn.Hidden = True

  Case "5"
      ws.Range("C:F,H:N").EntireColumn.Hidden = True

  Case "6"
      ws.Range("C:G,I:N").EntireColumn.Hidden = True



End Select

End Sub

By: Edvinas

Leave a Reply

Your email address will not be published. Required fields are marked *