I got a Calc file which contains data encoded in the color of cells (some cells are red and some are black. These cells indicate different values.
Is there a formula to get the color of a cell to extract this information?
A simplified example:
I got a Calc file which contains data encoded in the color of cells (some cells are red and some are black. These cells indicate different values.
Is there a formula to get the color of a cell to extract this information?
A simplified example:
Add this function adapted from How do I determine what color a Calc cell is?.
Function RGBprobe(x , y, optional z)
Dim RGBarray(1 to 3)
oDoc = ThisComponent
oSheet = oDoc.Sheets(0)
'Decreasing coordinate values by 1 because BASIC starts numbering with 0.'
If NOT IsMissing(z) Then oSheet = oDoc.Sheets(z-1)
oCell = oSheet.getCellByPosition(x-1,y-1)
CBkC = oCell.CharColor
RGBarray(1) = Red(CBkC) : RGBarray(2) = Green(CBkC) : RGBarray(3) = Blue(CBkC)
RGBprobe = RGBarray
End Function
Then enter =RGBPROBE(COLUMN()-1;ROW())
in cell C8 and drag to fill down.
This should only be a temporary solution. Once you have the values, put the data into another column, for example, “M” or “F”. Then if you still want the colors, remove the hard formatting and apply conditional formatting based on the M/F column.
Thank you! Just wanted to add that I did not make this file, I just wanted to import the data.