How to get CheckBox name in a cell?

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
The CheckBox is added by:

View/ToolBars/Forms/Checkbox

or View/ToolBars/Control ToolBox

I think It is acturally in the sheet.

I added 10 checkboxes in a column. Maybe I should link the checkbox to a cell. When I click a checkbox, it could change the value of the linked cell from True to False. But I don't know by VBA, when I click a checkbox, which one I have clicked?
 
Upvote 0
Hi shiazbj,

You're right, the checkbox code is associated with the sheet in which you created it.
Open the VBE, in the Project Explorer, locate the sheet name (e.g. Sheet1 (Sheet1)) and double-click it to open the code window.

The left most drop-down of the code window probably shows "General" at the moment. Click this drop-down and you should see the names of all the checkboxes you have created. As you select each, the default CheckBox#_Click() event is created.

you can get the name of the clicked checkbox using something along the lines of:

Private Sub CheckBox1_Click()
worksheets("Sheet1").Range("B2") = CheckBox1.Caption
End Sub

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,224,722
Messages
6,180,559
Members
452,987
Latest member
mrfitness_79

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