Sub New_Color()

  • Thread starter Thread starter Fan924
  • Start date Start date
F

Fan924

Sub New_Color()
ActiveWorkbook.Colors(4) = RGB(255, 0, 0)
End Sub

This works great. It changes color pallet number 4 to red.
When I put 255, 0, 0 in a cell and replace it with a variable, I get
black [not red] or an error message highlighting RGB. Any ideas?
 
VBA's RGB argument expects 3 parms passed to it (Red:=, Green:=, blue:=)--not a
string.

So you could parse your string and separate it into 3 different variables.

Personally, I think putting each of the values into separate cells would be
easier:

with activesheet
.parent.colors(4) = rgb(.range("A1").value, _
.range("B1").value, _
.range("C1").value)
end with

(The sheet's parent is the workbook that owns that sheet.)

Sub New_Color()
ActiveWorkbook.Colors(4) = RGB(255, 0, 0)
End Sub

This works great. It changes color pallet number 4 to red.
When I put 255, 0, 0 in a cell and replace it with a variable, I get
black [not red] or an error message highlighting RGB. Any ideas?
 
Back
Top