Kleuren in Excel/VBA

Een heel handig Color Picker is te vinden achter deze link Color Picker

2018-02-28 10_40_58-HTML Color Picker

 

 

 

 

 

 

 

Onderstaande link van David McRitchie brengt je naar alle kleurnummers voor VBA

http://dmcritchie.mvps.org/excel/colors.htm

 

Sub colors56()

’57 colors, 0 to 56
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual ‘pre XL97 xlManual
Dim i As Long
Dim str0 As String, str As String
Cells(1, 1) = “interior”
Cells(1, 2) = “font”
Cells(1, 3) = “HTML”
Cells(1, 4) = “bgcolor=”
Cells(1, 5) = “Red”
Cells(1, 6) = “Green”
Cells(1, 7) = “Blue”
Cells(1, 8) = “Color”
Range(“A1:H1”).Interior.ColorIndex = 16
For i = 0 To 56
Cells(i + 2, 1).Interior.ColorIndex = i
Cells(i + 2, 1).Value = “[Color ” & i & “]”
Cells(i + 2, 2).Font.ColorIndex = i
Cells(i + 2, 2).Value = “[Color ” & i & “]”
str0 = Right(“000000” & Hex(Cells(i + 2, 1).Interior.Color), 6)
‘Excel shows nibbles in reverse order so make it as RGB
str = Right(str0, 2) & Mid(str0, 3, 2) & Left(str0, 2)
‘generating 2 columns in the HTML table
Cells(i + 2, 3) = “#” & str ‘& “#” & str & “”
Cells(i + 2, 4) = “#” & str
Cells(i + 2, 4).Interior.ColorIndex = i
Cells(i + 2, 5).Formula = “=Hex2dec(“”” & Right(str0, 2) & “””)”
Cells(i + 2, 6).Formula = “=Hex2dec(“”” & Mid(str0, 3, 2) & “””)”
Cells(i + 2, 7).Formula = “=Hex2dec(“”” & Left(str0, 2) & “””)”
Cells(i + 2, 8) = “[Color ” & i & “)”
Next i
done:
Application.Calculation = xlCalculationAutomatic ‘pre XL97 xlAutomatic
Application.ScreenUpdating = True
End Sub

 

Categories: VBA