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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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