Hide/Show checkboxes in accordance with user input/interaction

Daugaard92

New Member
Joined
Nov 20, 2020
Messages
17
Office Version
  1. 2016
Platform
  1. Windows
I have an Excel-sheet, which contains 6 checkboxes and a few cells which requires user input.

The checkboxes are Active-X objects and I want the checkboxes visiblity to depend on the values in specific cells.
This means that I want each checkbox to be shown/hiden, dependant on the user input and value in specific cells.

For instance, I'd like CheckBox1 to be displayed, if the value in C15 <> 0.

After doing some research i created the following macro:

Private Sub Worksheet_Change(ByVal Target As Range)

If Range("C15").Value = 0 Then

Sheets("Ark1").CheckBox1.Visible = False

Else

Sheets("Ark1").CheckBox1.Visible = True

End If

End Sub

But the macro has no affect on the visibility of the CheckBox regardless of the changes being done to cell C15.

Is someone able to identify what I'm doing wrong and steer me on a correct course?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
A few questions.
1) Are the checkboxes on the same sheet as the cells being changed?
2) Is C15 being changed by user input?
3) Should the code check if C15 is zero, or empty?
4) did you put that code in the correct sheet module?
 
Upvote 0
A few questions.
1) Are the checkboxes on the same sheet as the cells being changed?
2) Is C15 being changed by user input?
3) Should the code check if C15 is zero, or empty?
4) did you put that code in the correct sheet module?
1) Yes, they are on the same sheet.
2) Yes, C15 is to be changed by the user. Its "standard" value is 0; So when the value changes in accordance with user input, I want a specific checkbox to be "unhidden".
3) The code should check, if the value is anything "other" than 0.
4) I'm not that experienced with relationships between modules and sheets; But there shouldn't be any issue, as shown in the picture below:
1608034783139.png
 
Upvote 0
Assuming you are working on the Ark1 sheet the code should be in that sheets module, not a standard module.
If, with the image in your prvious post, double click on Ark1(Ark1) is the code in the window that opens up?
 
Upvote 0
Solution
My god, that fixed it completely! Thanks so much!

I wasn't familiar with the concept of standard- and sheet-specific modules.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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