![]() |
|
#3
|
|||
|
|||
|
Or...
to address the request as asked... Code:
Sub Convert_Values_To_Colors()
Dim rng As Range, cel As Range
Dim celStr As String, celFontColor As Long, celFillColor As Long
On Error Resume Next
Set rng = Application.InputBox("With the mouse, select the range to work on.", "RANGE TO WORK WITH", Type:=8)
On Error GoTo 0
If Not rng Is Nothing Then
For Each cel In rng
Select Case cel.Value
Case Is = 0
celStr = "On-Hold"
celFontColor = RGB(225, 225, 225) 'White
celFillColor = RGB(0, 102, 204) 'Blue
Case Is = 10
celStr = "Green"
celFontColor = RGB(225, 225, 225) 'White
celFillColor = RGB(51, 153, 102) 'Green
Case Is = 20
celStr = "Amber"
celFontColor = RGB(0, 0, 0) 'Black
celFillColor = RGB(255, 255, 0) 'Yellow
Case Is = 30
celStr = "Red"
celFontColor = RGB(225, 225, 225) 'White
celFillColor = RGB(255, 0, 0) 'Red
End Select
With cel
If cel.Value <> "" Then
.Value = celStr
.Font.Color = celFontColor
.Interior.Color = celFillColor
End If
End With
Next cel
End If
End Sub
Here's a little procedure that will give you the RGB color of a cell so you can adjust the RGB to match. Code:
Sub GetRGBofCell()
Dim R As Integer
Dim G As Integer
Dim B As Integer
Dim RGB As Long
RGB = ActiveCell.Interior.Color
R = RGB And 255
G = RGB \ 256 And 255
B = RGB \ 256 ^ 2 And 255
MsgBox "RGB(" & R & ", " & G & ", " & B & ")"
End Sub
Last edited by NoSparks; 06-30-2018 at 09:22 PM. |
| Tags |
| excel 2013, macro, vba |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Footnote extraction macro [Why is this macro so slow? / anyway to make it faster?]
|
Le_Blanc | Word VBA | 10 | 03-22-2021 11:38 AM |
| Spell check macro within macro button field doesn't work in one document | samuelle | Word VBA | 0 | 07-20-2016 02:27 AM |
Macro Question: Need help making a macro to highlight the first word in every sentence
|
LadyAna | Word | 1 | 12-06-2014 10:39 PM |
| Macro Needed to bold specific lines and Macro to turn into CSV | anewteacher | Word VBA | 1 | 05-28-2014 03:59 PM |
| custom icon, undo/redo for macro, permanent macro | Rapier | Excel | 0 | 08-05-2013 06:30 AM |