Office 2007
I have made a crude meeting room booking system.
One of the additions I added was a cell to choose what week to view. Basically if you type week 1 in cell A2, the rest of the columns that contain the other weeks will be hidden.
This is my code. I am a scripting newbie, but I modified this to suit my sheet.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Changed As Range
Set Changed = Range("A2")
If Not Intersect(Target, Changed) Is Nothing Then
Range("B:CL").EntireColumn.Hidden = False
Select Case UCase(Target.Value)
Case "WEEK 1"
Range("J:CK").EntireColumn.Hidden = True
Range("B:I").EntireColumn.Hidden = False
Case "WEEK 2"
Range("B:I", "AD:CK").EntireColumn.Hidden = True
Range("J:AC").EntireColumn.Hidden = False
Case "WEEK 3"
Range("B:AC", "AX:CK").EntireColumn.Hidden = True
Range("AD:AW").EntireColumn.Hidden = False
Case "WEEK 4"
Range("B:AW", "BP:CK").EntireColumn.Hidden = True
Range("AX:BQ").EntireColumn.Hidden = False
Case "WEEK 5"
Range("B:BQ").EntireColumn.Hidden = True
Range("BR:CK").EntireColumn.Hidden = False
Case "Entire Month"
Range("B:CL").EntireColumn.Hidden = False
End Select
The code works perfectly.
However Once I linked a dropdown list (active x one) to the cell A2, and I choose the values from the Dropdown, the sheet will not hide/unhide the columns unless I double click on A2 as if to edit it and press enter.
Is there anyway to induce the changes through the dropdown so that I do not have to directly touch A2?
I have made a crude meeting room booking system.
One of the additions I added was a cell to choose what week to view. Basically if you type week 1 in cell A2, the rest of the columns that contain the other weeks will be hidden.
This is my code. I am a scripting newbie, but I modified this to suit my sheet.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Changed As Range
Set Changed = Range("A2")
If Not Intersect(Target, Changed) Is Nothing Then
Range("B:CL").EntireColumn.Hidden = False
Select Case UCase(Target.Value)
Case "WEEK 1"
Range("J:CK").EntireColumn.Hidden = True
Range("B:I").EntireColumn.Hidden = False
Case "WEEK 2"
Range("B:I", "AD:CK").EntireColumn.Hidden = True
Range("J:AC").EntireColumn.Hidden = False
Case "WEEK 3"
Range("B:AC", "AX:CK").EntireColumn.Hidden = True
Range("AD:AW").EntireColumn.Hidden = False
Case "WEEK 4"
Range("B:AW", "BP:CK").EntireColumn.Hidden = True
Range("AX:BQ").EntireColumn.Hidden = False
Case "WEEK 5"
Range("B:BQ").EntireColumn.Hidden = True
Range("BR:CK").EntireColumn.Hidden = False
Case "Entire Month"
Range("B:CL").EntireColumn.Hidden = False
End Select
The code works perfectly.
However Once I linked a dropdown list (active x one) to the cell A2, and I choose the values from the Dropdown, the sheet will not hide/unhide the columns unless I double click on A2 as if to edit it and press enter.
Is there anyway to induce the changes through the dropdown so that I do not have to directly touch A2?