auto color

muttley132

New Member
Joined
Nov 24, 2009
Messages
2
Hi people,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
i have a spread sheet with "pick from list" boxes, but i want to add a colour to the box automatically depending on the item that as been picked.<o:p></o:p>
<o:p> </o:p>
So, cell 1,A, I pick a persons name, I want the background of that cell in red.<o:p></o:p>
cell 2,A, another persons name, in another colour.<o:p></o:p>
<o:p> </o:p>
Any ideas how or if this can be done, and how easy is it.<o:p></o:p>
<o:p> </o:p>
Thanks in advance.<o:p></o:p>
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
47,926
Office Version
  1. 365
Platform
  1. Windows
This could possibly be done with Conditional Formatting or some vba code. It depends on what version of Excel you are using and how many different names/colours you want.

Edit: By the way, welcome to the MrExcel board!
 

muttley132

New Member
Joined
Nov 24, 2009
Messages
2
Hmm, vbl code, i have no idea what that is.
but thanks for your reply.
our spread sheet isnt that complex, i was just thinking it would stand out a bit better.

and thanks for the welcome ;)
 

imback2nite

Board Regular
Joined
Oct 30, 2004
Messages
113
Office Version
  1. 2007
I use something like this in VBA. What this does is whatever you put in the A1 through A4 range will change the color of the interior of the cell of where ever the same characters are found in the worksheet. For example. If you put “Ben” in cell A1 then where ever “Ben” is input into a cell it will change, in this case due to the ColorIndex, yellow. But the name must be exact. You can use the Validation function to ease this. This will work for you if you plan on using more than three names as the code can be extended. I use it in Excel 2003 and have had no problems.


Private Sub Worksheet_Change(ByVal Target As Range)

Dim cell As Range
Dim Rng1 As Range

On Error Resume Next
Set Rng1 = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, 1)
On Error GoTo 0
If Rng1 Is Nothing Then
Set Rng1 = Range(Target.Address)
Else
Set Rng1 = Union(Range(Target.Address), Rng1)
End If
For Each cell In Rng1
Select Case cell.Value
Case vbNullString
cell.Interior.ColorIndex = xlNone
cell.Font.Bold = False
Case Range("A1").Value
cell.Interior.ColorIndex = 6
Case Range("A2").Value
cell.Interior.ColorIndex = 43
Case Range("A3").Value
cell.Interior.ColorIndex = 54
Case Range("A4").Value
cell.Interior.ColorIndex = 39
Case Else
cell.Interior.ColorIndex = xlNone
cell.Font.Bold = False
End Select
Next

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,318
Messages
5,600,918
Members
414,416
Latest member
Nobu

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
Top