Hide Check Box with VBA Code

tlc53

Active Member
Joined
Jul 26, 2018
Messages
399
Hi there,

Trying to get this code to work but not having much luck. It currently does nothing.
Can anyone see where I am going wrong please? Thank you!

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target = Range("d8") = 1 Then
            ActiveSheet.CheckBoxes("CheckBox34").Visible = False
        Else
            ActiveSheet.CheckBoxes("CheckBox34").Visible = True
        End If
    
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I don't know if you've tried this, but the examples I found here show it as "Checkbox##" inside the quotes inside the parentheses. Note the lowercase 'b'. That's the only difference I can see.
 
Upvote 0
Thanks but that hasn't done it.
I tried the following which made it disappear however, it wouldn't come back :LOL:
Hmm.. not sure where to go from here..

Code:
    If Target = Range("D8") = 1 Then
            ActiveSheet.Shapes("Check Box 32").OLEFormat.Object.Visible = True
        Else
            ActiveSheet.Shapes("Check Box 32").OLEFormat.Object.Visible = False
        End If
    
End Sub
 
Upvote 0
Did it! :)

Code:
Private Sub Worksheet_Calculate()
    If ActiveSheet.Range("D8").Value = 1 Then
        ActiveSheet.Shapes("CheckBox34").Visible = False
    Else
        ActiveSheet.Shapes("CheckBox34").Visible = True
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top