I'm trying to create a function in Excel which returns the color of another cell. The idea is, that the function can be called as '=Background(A1)' - and then it should return the interior color of cell A1. This is what I came up with:
Public Function Background(Data As Range) As Double
Dim nBackgroundcolor As Double
nBackgroundcolor = 0
nBackgroundcolor = Worksheets("Sheet1".Data.Interior.ColorIndex
Background = nBackgroundcolor
End Function
The problem is that, when I debug, 'Data' does not contain 'A1', but the contents of A1. How do I do this?
Thanks in advance!
Public Function Background(Data As Range) As Double
Dim nBackgroundcolor As Double
nBackgroundcolor = 0
nBackgroundcolor = Worksheets("Sheet1".Data.Interior.ColorIndex
Background = nBackgroundcolor
End Function
The problem is that, when I debug, 'Data' does not contain 'A1', but the contents of A1. How do I do this?
Thanks in advance!