ComboBox BackColor change on value

KennyA

Board Regular
Joined
Jul 1, 2015
Messages
84
I have a ComboBox that I am trying to get the BackColor to change based on a selection.
There are 11 ComboBoxes on the sheet. After I have gone through all the boxes and made the selections
I hit the finish button which runs the VBA code.

Using ActiveX ComboBox. This is the code I tried using. I am obviously doing something wrong.
I want TERMINAL BOX to be green and NONE to be red

With ComboBox11
Select Case .Value
Case "TERMINAL BOX"
.BackColor = &HFF00&
Case "NONE"
.BackColor = &HFF&
Case Else
.BackColor = &HFF00&
End Select
End With
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
In that case I don't see how the back colour would change if you used
Code:
With ComboBox11
    Select Case .Value
        Case "Yes"
        .BackColor = &HFF00&
        Case "No"
        .BackColor = &HFF&
        Case Else
        .BackColor = &HFF00&
    End Select
End With
if Yes and No are not one of the values in the combo.
 
Upvote 0
OK, because it's case sensitive, try
Code:
    With Me.ComboBox1
        Select Case LCase(.Value)
            Case "terminal box"
                .BackColor = &HFF00&
            Case "none"
                .BackColor = &HFF&
            Case Else
                .BackColor = &H80000005
        End Select
    End With
 
Upvote 0
I tried that code as well and still the BackColor did not change.
I am starting to wonder if this particular code set only works with YES or NO values
 
Upvote 0
I got it to work. I had to run the code on the sheet in VBA. Originally I was running it from a Module. Thank you for all your help!!!

With ComboBox11
Select Case .Value
'Case "YES"
'.BackColor = &HFF00&
Case "NONE"
.BackColor = &HFF&
Case Else
.BackColor = &HFF00&
End Select
End With
 
Upvote 0
Glad you got it sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,409
Messages
6,119,339
Members
448,888
Latest member
Arle8907

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