ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combo box background colour (https://www.excelbanter.com/excel-programming/341319-combo-box-background-colour.html)

John Davies

Combo box background colour
 
I have a combo box and it is linked to a cell a2.
When I select a value from the combo box drop down list this obviously
changes the value in cell A2. Is it possible to have the background of the
como box automatically change colour depending on the value of cell a2?
e.g. Cell A2 = 1, combo box background = red
Cell A2 = 2, combo box background = green
Cell A2 = 3, combo box background = blue
Thanks for any help

Mike Fogleman

Combo box background colour
 
Try this in the combobox_change event code:

Private Sub ComboBox1_Change()
If Range("A2").Value = 1 Then Me.ComboBox1.BackColor = RGB(255, 0, 0)
If Range("A2").Value = 2 Then Me.ComboBox1.BackColor = RGB(0, 255, 0)
If Range("A2").Value = 3 Then Me.ComboBox1.BackColor = RGB(0, 0, 255)
End Sub

Mike F
"John Davies" wrote in message
...
I have a combo box and it is linked to a cell a2.
When I select a value from the combo box drop down list this obviously
changes the value in cell A2. Is it possible to have the background of
the
como box automatically change colour depending on the value of cell a2?
e.g. Cell A2 = 1, combo box background = red
Cell A2 = 2, combo box background = green
Cell A2 = 3, combo box background = blue
Thanks for any help





All times are GMT +1. The time now is 04:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com