I have a user defined function in Excel. It is called as a formula function from spreadsheet cells and works fine.
I\'d like the function to be able to change the ce
Function HexToLongRGB(sHexVal As String) As Long
Dim lRed As Long
Dim lGreen As Long
Dim lBlue As Long
lRed = CLng("&H" & Left$(sHexVal, 2))
lGreen = CLng("&H" & Mid$(sHexVal, 3, 2))
lBlue = CLng("&H" & Right$(sHexVal, 2))
HexToLongRGB = RGB(lRed, lGreen, lBlue)
End Function
Function setBgColor(ByVal stringHex As String)
Evaluate "setColor(" & Application.Caller.Offset(0, 0).Address(False, False) & ",""" & stringHex & """)"
setBgColor = ""
End Function
Sub setColor(vCell As Range, vHex As String)
vCell.Interior.Color = HexToLongRGB(vHex)
End Sub