I'm using Excel for Mac 2011, and I have a couple Check Boxes in one sheet. I'm trying to automate them with the following code:
Private Sub CheckBox12_Click()
Dim ws As Worksheet
Set ws = ActiveSheet
With ws
If .Shapes("CheckBox12").OLEFormat.Object.Value = xlOn Then
.Range("CK1").EntireColumn.Hidden = False
Else
.Range("CK1").EntireColumn.Hidden = True
End If
End With
End Sub
This code gives me the error: Run-time error 445 Object does not support this action.
However if remove ws and just do
Private Sub CheckBox12_Click()
With ActiveSheet
If .Shapes("CheckBox12").OLEFormat.Object.Value = xlOn Then
.Range("CK1").EntireColumn.Hidden = False
Else
.Range("CK1").EntireColumn.Hidden = True
End If
End With
End Sub
This works just fine.
What's the deal here? I know I can just use ActiveSheet, but I always like to first set it = ws because it gives the dropdown list of properties/methods as I code.