I have two macros running in a worksheet but one is functioning via a toggle button and the other is a drop down list which uses a change event.
I've made some modifications to the spreadsheet and now need a formula to detect the toggle button value.
I figured it would be best to get rid of the toggle button and clean up the worksheet with two drop down lists; however, when I do, the macro crashes.
Is there a way of fixing this?
Here's the original macros which work fine.
I just want to change the toggle button to activate based on the value of Cell L8.
I've made some modifications to the spreadsheet and now need a formula to detect the toggle button value.
I figured it would be best to get rid of the toggle button and clean up the worksheet with two drop down lists; however, when I do, the macro crashes.
Is there a way of fixing this?
Here's the original macros which work fine.
I just want to change the toggle button to activate based on the value of Cell L8.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("U13")) Is Nothing Then Exit Sub
Select Case Target.Value
Case "Auto Entry"
Range("AP:AS").EntireColumn.Hidden = True
Case "Manual Entry"
Range("AP:AS").EntireColumn.Hidden = False
End Select
End Sub
Code:
Private Sub ToggleButton5_Click()
Worksheets("Macro Test").Activate
ActiveSheet.Unprotect ("")
Application.ScreenUpdating = False
If ToggleButton5.Value = True Then
'This area contains the things you want to happen
'when the toggle button is not depressed
ToggleButton5.BackColor = &H8000000F
ToggleButton5.ForeColor = RGB(0, 0, 0)
ToggleButton5.Caption = "Activate Option-A
Range(Columns(18), Columns(20)).EntireColumn.Hidden = True
Range(Columns(32), Columns(41)).EntireColumn.Hidden = True
Range(Columns(15), Columns(17)).EntireColumn.Hidden = False
Range(Columns(22), Columns(31)).EntireColumn.Hidden = False
Else
'This area contains the things you want to happen
'when the toggle button is depressed
ToggleButton5.BackColor = RGB(146, 208, 80)
ToggleButton5.ForeColor = RGB(0, 0, 0)
ToggleButton5.Caption = "Activate Option-B"
Range(Columns(18), Columns(20)).EntireColumn.Hidden = False
Range(Columns(32), Columns(41)).EntireColumn.Hidden = False
Range(Columns(15), Columns(17)).EntireColumn.Hidden = True
Range(Columns(22), Columns(31)).EntireColumn.Hidden = True
ActiveSheet.Protect ("")
Application.ScreenUpdating = True
End If
End Sub