CheckBox Label

  • Thread starter Thread starter Pablo
  • Start date Start date
P

Pablo

How do you make a checkbox label equal a cell input?

For example, the cell A3 = "Blue", how do you make the label for the check
box say "Blue" so that if I change A3 to "Red" the checkbox label will now
say "Red"?
 
Hi Pablo!

You can use a macro that update he checkbox label, like the sample below:

1. Open the workbook where you want this macro
2. Open the Visual Basic editor (Tools, Macro, Visual Basic Editor)
3. In the Project window, doubleclick on the "Sheet1" object (or the
sheetname where you have the check box and cell where you enter the checkbox
label) in "Microsoft Excel objects" for this workbook.
4. Paste the code below to the Code-window and
- change the cell-address to the cell where you enter the label for the
check box (cell A1 in the sample)
- the name of the checkbox you use (if you don't know the name, then you can
rightlick the checkbox in the worksheet and see the name in the namebox to
the left of the formula field)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
xx = ActiveCell.Address
CheckBoxName = Range("a1").Text 'Here you can change the
cell-address where you have the name for the check box.
ActiveSheet.Shapes("Check Box 1").Select 'Here you can change the
name of your check box
Selection.Characters.Text = CheckBoxName
Range(xx).Select
End Sub

Now when you change the name for the checkbox in the cell, the
checkbox-label is updated.


Best regards

Stefan Hägglund
Microsoft
 
Back
Top