Conditional Format an Image Color in Excel

lshappell

New Member
Joined
Aug 27, 2014
Messages
1
I am in the process of trying to create a custom map in excel and would like for various regions of the map to change color based on various cell based criteria. At this point I am just trying to get the "images" (as I have drawn them) to change color. I assume that this would be fairly simple if I were better with VBA. Anyone have any ideas?
Thank you!
 
Hello and welcome to the Board

Try something like this:

Code:
Sub ColorMap()
Dim c As Range
For Each c In ActiveSheet.UsedRange.Cells
    Select Case c.Value
        Case Is < 1: FormatRange c, 2, 35, 145
        Case Is < 3: FormatRange c, 222, 33, 45
        Case Is < 5: FormatRange c, 67, 212, 187
        Case Is < 7: FormatRange c, 111, 123, 231
        Case Is < 9: FormatRange c, 67, 98, 217
        Case Is < 12: FormatRange c, 156, 76, 92
        Case Is < 15: FormatRange c, 167, 231, 21
        Case Is < 20: FormatRange c, 212, 145, 52
        Case Is < 25: FormatRange c, 32, 78, 149
        Case Is < 30: FormatRange c, 176, 21, 254
        Case Is < 35: FormatRange c, 67, 231, 34
        Case Is < 45: FormatRange c, 243, 12, 78
        Case Is < 45: FormatRange c, 23, 129, 178
        Case Is < 60: FormatRange c, 12, 222, 222
        Case Is < 90: FormatRange c, 222, 222, 2
        Case Is < 120: FormatRange c, 222, 2, 222
        Case Is < 150: FormatRange c, 2, 212, 253
        Case Is < 200: FormatRange c, 222, 187, 121
        Case Else: FormatRange c, 189, 231, 195
    End Select
Next
End Sub


Sub FormatRange(rn As Range, r%, g%, b%)
rn.Interior.Color = RGB(r, g, b)
rn.Font.Color = RGB(r, g, b)
End Sub
 
Upvote 0
...and sheets like this can be generated:
flag.JPG
 
Upvote 0

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