Sum if cell style is...

Discuss the spreadsheet application
Post Reply
dentopolis
Posts: 19
Joined: Mon Sep 23, 2013 2:44 pm

Sum if cell style is...

Post 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?
LibreOffice 7.4
User avatar
Zizi64
Volunteer
Posts: 11360
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Sum if cell style is...

Post 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.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11360
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Sum if cell style is...

Post 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.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
robleyd
Moderator
Posts: 5085
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Sum if cell style is...

Post by robleyd »

See also this discussion on the same topic.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Sum if cell style is...

Post 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.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply