This is very different to what I have found in searches using this question.
I want to be able to change font size and color (RGB) based on cell values for a range. This would allow users to customize a form (size and colour of headings, general text, etc.)
For font size, this, below, works perfectly, but it doesn't work for font colour unless I specify the colour in the code.
Cell B1 contains the font size, 12, and cell B2 contains 255, 255, 0
Sub fontsizecolor ()
Dim rgb2 As String
rgb2 = ThisWorkbook.Worksheets("sheet1").Range("B2").Text
With Worksheets("Sheet1").Range("A1:A10")
.Font.Size = Range("B1")
'.Font.Color = RGB(255, 255, 0) **<---- this works**
.Font.Color = RGB(rgb2)
End With
End Sub
RGB
expects 3 numeric arguments. You are passing it one string. You need to either parse the string into 3 arguments, perhaps usingSplit
, or put the 3 numeric values in 3 different cells. – BigBen