Check CheckBox automaticly when specific value in ComboBox is set

ThaBodenZ

New Member
Joined
Oct 16, 2017
Messages
5
Hi!

I've got myself stuck, I have 20 Checkboxes and 20 ComboBoxes next to each other. In the ComboBoxes there're five different values to chose from, if one out of four of the five values in one ComboBox is choosen, I want the CheckBox next to it to be filled in. I don't want it to be checked as soon as one of the values is selected, just if one of four out of the five different values is set.

Do anybody have any idea of what kind of VBA-code I need to do this?
I was thinking that maby if the Value is serching for a specific term to be in the ComboBox that would triger the CheckBox, but no. But anyways this is my code as it stands, please take in perspective that this is the first time I use VBA and have looked everywhere online without any sucess.


Private Sub ComboBox1_Change()
If Sheet1.ComboBox1("ComboBox1").Value = "Name" Then
Range("Sheet1.CheckBox.1").Value = xlOn
Else
Range("Sheet1.CheckBox.1").Value = xlOff
End If


End Sub




PS! *Name* in this code is one of the values you can chose from in the ComboBox!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Welcome to MrExcel

Have you looked at:

Code:
CheckBox1.Value = ComboBox1 = "Name"
 
Upvote 0
Thank you for your answer! Tho I get "Runerror 424 - Object is needed" and the "f Sheet1.ComboBox1("ComboBox1").Value = "Name" Then"-row is highlighted as the cause of the error, even with your code unfortunately.
 
Upvote 0
Sorry; I assumed you would put the code in the module of the sheet that has the ComboBox1 and CheckBox1...

In developer mode..

Ctrl R
Double click sheet with the objects ComboBox1 and CheckBox1

Put in the code:

Code:
Private Sub ComboBox1_Change()
[B]    CheckBox1.Value = ComboBox1 = "Name"
[/B]End Sub
 
Upvote 0
Wonderful! Thank you! But if I want the checkbox to be filled when another "Name" is set in the ComboBox, ("Name" is four different namnes, and the fifth value that I don't want the checkbox to be filled when set is "Not done yet") I can't get it right. Do you know if there is anyting I need to change to get it to work with different names? :)
 
Upvote 0
Code:
Private Sub ComboBox1_Change()
    CheckBox1.Value = ComboBox1 <> "Not done yet"
End Sub
 
Upvote 0
Thank you so much! You just saved my *** haha! One last thing if you please, how do I make the "Not done yet" value the Default? :)
 
Upvote 0
Code:
Const NDY = "Not done yet"
Private Sub ComboBox1_Change()
    CheckBox1.Value = ComboBox1 <> NDY
End Sub

Private Sub Worksheet_Activate()
    If Len(Trim(combox1)) = 0 Then combox1 = NDY
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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