Page 1 of 1

Sum if cell style is...

PostPosted: Fri May 08, 2020 10:03 pm
by dentopolis
i'd like to sum cell that have some style, for example "green". is there any visual basic code, function to try? or existing solution?

Re: Sum if cell style is...

PostPosted: Fri May 08, 2020 10:41 pm
by Zizi64
Never use a formatting property as some valid spreadsheet data.

Use helper cells and some numeric or textual contents to mark the cells to summarize.

Re: Sum if cell style is...

PostPosted: Fri May 08, 2020 10:44 pm
by Zizi64
is there any visual basic code, function to try?

The AOO/LO has not built-in VBA feature.

The built-in StarBasic+API of the AOO/LO and the MS VBA are basically different tools.

Yes, it is possible to write a macro that will read the name of the applied Cell Style in a desired cell range, and then it summarize the numeric contents of the cells that have same Cell Style.
But it is better to follow my first suggestion in my post above.

Re: Sum if cell style is...

PostPosted: Sat May 09, 2020 1:49 am
by robleyd
See also this discussion on the same topic.

Re: Sum if cell style is...

PostPosted: Sat May 09, 2020 2:23 am
by Villeroy
viewtopic.php?t=42114&p=194261#p194261 has a document with some user-defined functions to help fixing broken sheets where information is hidden in formatting attributes. There is also a function CELL_STYLE to extract the style name. You can convert this information into a better solution with conditional formatting and with built-in functions such as SUMIF, SUMPRODUCT, filtering, pivot tables or whatever Calc has to offer. With info in attributes you are bare of options.