Check box if cell value is X

Lizabeta

New Member
Joined
Oct 24, 2008
Messages
32
I've seen lots of posts about updating a cell value based on whether or not a checkbox is marked or unmarked.

Is there a way to do the opposite?

If A1 = X then checkbox = true/checked?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi Lizabeta,

Try this:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("A1") = "X" Then
        CheckBox1.Value = True
    Else
        CheckBox1.Value = False
    End If
End Sub
 
Upvote 0
So if I had more than one check box, I would just put the code (attached to the indivdual check box) and substitute Checkbox1.Value with the number of the next box... Like... Checkbox2.Value for the second, Checkbox3 for the third... Correct?

And then for each checkbox, the code will look in the cell and I could replace the "X" with... "Spanish" "English" or whichever one that box is testing for, also correct?

For instance:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("A1") = "Spanish" Then
        CheckBox2.Value = True
    Else
        CheckBox2.Value = False
    End If
End Sub
 
Upvote 0
Okay... so it's not each indivdual box... you add an additional IF statement after the End If, Like this:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("A1") = "Spanish" Then
        CheckBox1.Value = True
    Else
        CheckBox1.Value = False
    End If
    If Range("A1") = "Vietnamese" Then
        CheckBox2.Value = True
    Else
        CheckBox2.Value = False
    End If
End Sub

This works wonderfully! Thank you!
 
Upvote 0
What do you mean?
Code:
 if I had more than one check box
All CheckBox values (for example CheckBox5, CheckBox2, CheckBox4 … ) should be depended from one cell value (for example A1)? Or
For example CheckBox2 from A8, CheckBox5 from A3, ....?
 
Upvote 0
Cell A1 returns the value of which language is being used (Through a whole 'nother INDIRECT formula, based on the sheet name)
So every box will be looking at the same cell.

The code in my previous reply, where CheckBox1 and CheckBox2 both looked in A1 and tested for the language works perfectly! If I change A1, the check mark pops over to the correct box.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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