comboBox colour change depending on selection

bensplace

New Member
Joined
Feb 7, 2013
Messages
4
I am using excel 2007 and i want to change the background colour of a combBox(Active control) depending on what is selected.
So I have a simple Yes/No selection that is blank to start off with.
When it is blank i want the colour to be default, but when you choose Yes i want the backgroung to change to green and when No is selected i want the colour to change to red.
I know I can do this in VBA but I do not know the code to use.
If any one can help me you may well get me a gold star at work

Thanks for looking
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
try this:

Code:
Private Sub ComboBox1_Change()

With ComboBox1
    Select Case .Value
        Case "yes"
        .BackColor = &HC000&
        Case "no"
        .BackColor = &HFF&
        Case Else
        .BackColor = &H80000005
    End Select
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,647
Messages
6,126,006
Members
449,280
Latest member
Miahr

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