![]() |
Changing color background in a range from a drop down
How can you make a range of cells in a row, change the background color based
on the option picked from a drop down. |
Changing color background in a range from a drop down
Make the dropdown from Data Validation list. Set the Conditional Format of all the cells you want to change colour look at that Data Validation cell using a formula in CF. -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=155269 Microsoft Office Help |
Changing color background in a range from a drop down
Hi Kwitt
Use a combobox from the Control Toolbar, add a list fill range to the combobox and paste this code in the sheet where the combobox exits. Finally change the variables in this example to suit your needs. Take care Marcus Option Explicit Private Sub ComboBox1_Change() Dim x As String x = ComboBox1.Value ' Place a value in x. ' Start the Select Case structure. Select Case x Case "One" Range("A1").Interior.Color = vbGreen Case "Two" Range("A1").Interior.Color = vbRed Case "Three" Range("A1").Interior.Color = vbBlue Case Else 'Every other possibility. Range("A1").Interior.Color = vbYellow End Select End Sub |
Changing color background in a range from a drop down
Marcus,
Thank you!! Ok I got it to change color. In addition to the color change I need each combobox to be associated with only 1 row and the color changes would be for only that row. How do you do that?? I have tried but continue to get error statements. For example cell $H$5 will contain the drop down and Green has been choosen, so row 5 from column A - Y will than change to the green color. And then cell $H$6 will have its own drop down and they have choosen Yellow, so then row 6 from column A-Y will then be changed to Yellow. "marcus" wrote: Hi Kwitt Use a combobox from the Control Toolbar, add a list fill range to the combobox and paste this code in the sheet where the combobox exits. Finally change the variables in this example to suit your needs. Take care Marcus Option Explicit Private Sub ComboBox1_Change() Dim x As String x = ComboBox1.Value ' Place a value in x. ' Start the Select Case structure. Select Case x Case "One" Range("A1").Interior.Color = vbGreen Case "Two" Range("A1").Interior.Color = vbRed Case "Three" Range("A1").Interior.Color = vbBlue Case Else 'Every other possibility. Range("A1").Interior.Color = vbYellow End Select End Sub . |
Changing color background in a range from a drop down
Which version of Excel? If 2003 or earlier, how many choices in the dropdown? -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=155269 Microsoft Office Help |
All times are GMT +1. The time now is 02:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com