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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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,224,523
Messages
6,179,301
Members
452,904
Latest member
CodeMasterX

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