How to sum() only cells where certain color is set
Is it possible to selectively sum only those cells in a range where the data color property is set to a certain color ( I have used Red3 and Green3 FWIW )
I have mused over a function to do this, I'm not a spreadsheet programmer, and I do not want to reinvent the wheel, but acting selectively on a selection does not seem to be something weird, I just cannot find an existing answer.
I thought about some pseudocode.
SumQualifiedRange ( the_range, the_color ) { Int nSum, nrlow, nrhigh, nColumn, nRow; nrlow = range_low(the_range); nrhigh = range_low(the_range); nSum=0; nColumn=column(the_range); For nRow=nrlow to nrhigh { If cell( nRow, nColumn ).properties.color = the_color { nSum=nSum+ cell( nRow, nColumn).value; } } return nSum; }
Hmmm.
SUMIF() woulod be good if we could test the color there.
See an old question: https://ask.libreoffice.org/en/questi...
"SumQualifiedRange ( the_range, the_color )" It is not possible to pass a cell range object to a Basic function. Only the content of the selected cellrange will be passed with ByVal method, but will not passed the other properties of the range like the absolot coordinates or formatting properties. You can pass:
You must get the specific cellrange by your macro based on these values. Then you will able to examine the formatting properties of the individual cells in the cell range.