Hi All,
I'm currently trying to come up with a VBA module that aims at grouping all columns whose date are past (against today's date). Date to check against are located in row 2 of Sheet1.
I would like the macro to execute upon the workbook opening only.
This is what I did so far but VBA returns a "run mismatch error". Any idea what i did wrong?
Private Sub Workbook_Open(ByVal Target As Range)
Dim xCell As Range
If Target.Address <> Range("A1").Address Then Exit Sub
Application.ScreenUpdating = False
For Each xCell In Rows(2)
xCell.EntireColumn.Group = (xCell.Value < Target.Value)
Next
Application.ScreenUpdating = True
End Sub
Bear with my question, I'm a beginner in VBA world.
Thank you very much in advance for your time and answers.
I'm currently trying to come up with a VBA module that aims at grouping all columns whose date are past (against today's date). Date to check against are located in row 2 of Sheet1.
I would like the macro to execute upon the workbook opening only.
This is what I did so far but VBA returns a "run mismatch error". Any idea what i did wrong?
Private Sub Workbook_Open(ByVal Target As Range)
Dim xCell As Range
If Target.Address <> Range("A1").Address Then Exit Sub
Application.ScreenUpdating = False
For Each xCell In Rows(2)
xCell.EntireColumn.Group = (xCell.Value < Target.Value)
Next
Application.ScreenUpdating = True
End Sub
Bear with my question, I'm a beginner in VBA world.
Thank you very much in advance for your time and answers.