Change pattern colour linked to content

Matthew

New Member
Joined
Apr 16, 2002
Messages
23
Not sure if someone has asked this before, if so I can not find it.

I have a sheet that needs to be formatted for printing. The text in the file is a lookup form a different sheet.

What I am trying to do is colour code thing ie if the cell is YEL and change colour to Yellow, BLU to Black and so on.

Any help would be appreciated.


1 2 3 4 5 6 7 8 9 10 11 12 13
1 YEL BLU NAT NAT BLU BLU BLK BLK BLU NAT NAT BLK BLK
100 0 0 0 0 0 65 0 0 0 55 140 125
2 YEL BLU NAT NAT BLU BLU BLK BLK BLU NAT NAT BLK BLK

3 YEL BLU NAT NAT BLU BLU BLK BLK BLU NAT NAT BLK BLK
100 0 0 0 0 0 65 0 0 0 55 140 125
4 YEL BLU NAT NAT BLU BLU BLK BLK BLU NAT NAT BLK BLK
100 0 0 0 0 0 65 0 0 0 55 140 125
5 YEL BLU NAT NAT BLU BLU BLK BLK BLU NAT NAT BLK BLK
100 0 0 0 0 0 65 0 0 0 55 140 125
6 YEL BLU NAT NAT BLU BLU BLK BLK BLU NAT NAT BLK BLK
100 0 0 0 0 0 65 0 0 0 55 140 125
7 YEL BLU NAT NAT BLU BLU BLK BLK BLU NAT NAT BLK BLK
100 0 0 0 0 0 65 0 0 0 55 140 125
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi,

Yes have looked at conditional formatting but am looking at up to 12 different colours

Thanks
 
Upvote 0
Code like this should work when put in the sheet's code module
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim keyRange As Range
    Dim oneCell As Range
    Set keyRange = Range("A1:B10")
    If Not Application.Intersect(keyRange, Target) Is Nothing Then
        For Each oneCell In Application.Intersect(keyRange, Target)
            With oneCell
                Select Case UCase(CStr(.Value))
                    Case "BLU"
                        .Interior.Color = vbBlue
                    Case "GRN"
                        .Interior.Color = vbGreen
                    Case "PUR"
                        .Interior.Color = RGB(255, 0, 255)
                    Case "etc"
                    
                    Case Else
                        .Interior.ColorIndex = xlNone
                End Select
            End With
        Next oneCell
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

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