Reputation: 7
Quite new to excel and VBA....I want to hide certain buttons on my excel sheet based on if a reference cell is empty or not. So the button should show if the reference cell contains any value, and should not be visible if the reference cell is empty. When I run my code, I get a Run-time error : Object doesn't support this property or method. I have renamed all of my buttons on my sheet. I'm not sure what the problem is. See code below....
Sub hideshowcheckboxes()
Application.ScreenUpdating = False
Sheets("Dispatch TOOL").Select
If Range("D12").Value = " " Then
Sheets("Dispatch TOOL").check1.Visible = False
Else
Sheets("Dispatch TOOL").check1.Visible = True
End If
Application.ScreenUpdating = True
End Sub
Upvotes: 0
Views: 2251
Reputation: 3337
The type of CheckBox Control that you use matters. To use a form control use the second approach.
Sub test()
'ActiveX Object
Sheet1.CheckBox1.Visible = True
'Form Control Object
Sheet1.Shapes("Check Box 2").Visible = False
End Sub
Upvotes: 1