8

I'm trying to change the value of my checkbox to true based on a another cell's value

if range("A1").value = "green" then
Checkbox1.value= true

end if 

How to I change the value property to true for multiple checkbox at the same time

For some reason the code that i've tried doesn't do anything at all. P.S. I'm using format checkboxes

4 Answers 4

10

This will change all Checkboxes

Sub Changeboxes()

    Dim cb As CheckBox

    If Sheet1.Range("a1").Value = "green" Then
        For Each cb In Sheet1.CheckBoxes
            cb.Value = True
        Next cb
    End If

End Sub

If you need to specify particular checkboxes, then

Sub ChangeSomeCbs()

    If Sheet1.Range("a1").Value = "green" Then
        Sheet1.CheckBoxes("Check Box 1").Value = True
        Sheet1.CheckBoxes("Check Box 2").Value = False
        Sheet1.CheckBoxes("Check Box 3").Value = True
    End If

End Sub

Checkbox and Checkboxes are hidden properties. You won't get intellisense, but they work.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm trying to specify the checkboxes on my form that I want to put a check mark in. For example for checkbox1 , I want the user to see it ticked.
0

This works fine for me:

If range("O26").Value = "green" Then
    CheckBox1.Value = True
    CheckBox2.Value = True
End If

If you are in design mode this will not work.

1 Comment

The code gives me an object required error(424) I've also tried to put an And after my first Checkbox.value = true statement but it doesn't work.
0

This code is true for Office365:

If range("O26").Value = "green" Then
    CheckBox1 = True
    CheckBox2 = True
End If

Comments

0

For ActiveX checkboxes, use this format:

ActiveSheet.OLEObjects("Checkbox1").Object.Value = True

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.