Hello,
I am trying to hide a range of columns based on a month in a date of a cell. There is some formula calculating number of months between two dates, essentially giving me a number between 1 and 48.
I found a macro, which I used, however it happens every time I click on a cell and takes ~4 seconds to finish.
Is there a way to insert this into the excel Date Picker? That only when its used, it ll launch the macro - something like a standard button would - or optimize this somehow?
Below are first Three parts, it continues 45 more times -.-
Thank you
Code
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set KeyCells = Range("E4:E7")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
If Range("F2").Value < 1 Then
Columns("K:L").EntireColumn.Hidden = True
Else
Columns("K:L").EntireColumn.Hidden = False
End If
If Range("F2").Value < 2 Then
Columns("M:N").EntireColumn.Hidden = True
Else
Columns("M:N").EntireColumn.Hidden = False
End If
If Range("F2").Value < 3 Then
Columns("O:P").EntireColumn.Hidden = True
Else
Columns("O:P").EntireColumn.Hidden = False
End If
Display More