Hiding checkboxes based on cell value

MissingInAction

Board Regular
Joined
Sep 20, 2019
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Hi everyone.
I'm busy creating an application form where users would apply for network, phone, etc. access from the IT department. In an effort to make the form as simple as possible for users to understand, I'm making use of quite a few conditional formatting, data validations, etc.
My question is this. I have a question on the form asking if the user needs computer equipment. If the answer is yes (answer is in E37), I want checkboxes to be visible so that the user can select things like laptops, desktops, etc.
The first prize would be if I could do this without VBA code, but I doubt that is possible. I have tried the solution I found here: Hide Checkbox based on cell value but it did not work in my case. Here is the code I'm using, modified from the previously mentioned thread:
VBA Code:
Private Sub Equipment_Change()
    If ActiveSheet.Range("E37").Value = "Yes" Then
        ActiveSheet.Shapes("Equipment").Visible = False
    Else
        ActiveSheet.Shapes("Equipment").Visible = True
    End If
End Sub

I do have a checkbox on that sheet called "equipment". I have written "equipment" in the name box next to the formula bar. I assume this is the correct place. I have tried both the form control checkbox and the Active X checkbox (renaming both "equipment"), since I do not know what the difference is, apart from some of the right click options that changes.

Thank you
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

mart37

Well-known Member
Joined
Aug 4, 2017
Messages
1,096
Office Version
  1. 2016
Platform
  1. Windows
The namebox is for giving names to a cell!
You need to use a name like: ActiveSheet.Shapes("CheckBox1")
 

MissingInAction

Board Regular
Joined
Sep 20, 2019
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Are you saying it will not accept that name if I type it in the namebox? When I view the source for the tick box, it opens VBA and shows the following:
VBA Code:
Sub Equipment_Click()

End Sub
I therefor assumed it accepted the name.
 

mart37

Well-known Member
Joined
Aug 4, 2017
Messages
1,096
Office Version
  1. 2016
Platform
  1. Windows
You are right.
Maybe you can use an other event: Worksheet_Change

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If ActiveSheet.Range("E37").Value = "Yes" Then
            ActiveSheet.Shapes("Equipment").Visible = True
        Else
            ActiveSheet.Shapes("Equipment").Visible = False
    End If
End Sub
 
Solution
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,020
Messages
5,856,844
Members
431,836
Latest member
jj0911

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
Top