[Solved] Do not sum hidden cells in columns

Discuss the spreadsheet application
Post Reply
restorwoodwindows
Posts: 1
Joined: Tue May 31, 2022 1:29 am

[Solved] Do not sum hidden cells in columns

Post by restorwoodwindows »

I've been searching for the answer and can't seem to find a decent answer so here goes.

I want to calculate the SUM of all the VISIBLE cells across my columns. There are a number of columns that are hidden and I don't need those cells included in the total.

So the function is horizontal across the spreadsheet and not vertical.

I appreciate the help!
 Edit: Changed subject, was Do Not Calculate Hidden Cells in Column Totals 
Make your post understandable by others 
The sum of cells across columns is a total for that row, not a "column total". 
-- MrProgrammer, forum moderator 
Last edited by MrProgrammer on Wed Jun 08, 2022 6:06 pm, edited 4 times in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
Todd T
Medium Exp Open Office Dude
Open Office 4.1.6 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11476
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Do not include hidden cells in row totals

Post by Zizi64 »

The function SUBTOTAL(109;range) works for rows when some rows are hidden.
But it seems not work when I use it for columns.

(LibreOffice 6.1.6)
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
MrProgrammer
Moderator
Posts: 5258
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Do not include hidden cells in columns

Post by MrProgrammer »

restorwoodwindows wrote: Tue May 31, 2022 1:32 am I want to calculate the SUM of all the VISIBLE cells across my columns. There are a number of columns that are hidden and I don't need those cells included in the total.
You cannot hide cells. You can hide columns, and you can hide rows. In this situation you seem to be hiding columns.

The basic problem is that formula calculations are based on cell values, not on row/column visibility or other formatting. However, I know two ways to accomplish this, though neither is entirely satisfactory to me as the process is not fully automatic. But that is to be expected when one wants to do something that Calc doesn't support.

You can use a row containing cells in its columns to indicate whether you want the column included in the total. When you change the values in row 2 of my attachment this affects whether the respective column(s) are considered in the total. But you must set the values in row 2 to FALSE before you hide columns and set them to TRUE after you show them.

You can use the =CELL("WIDTH") formula to calculate whether to include the column as you hide or show it. But the CELL() function is not recalculated automatically with the hide/show operations. You must press ⇪⌘F9 (Shift+Command+F9) on a Mac or Ctrl+Shift+F9 on other platforms to force the recalculation of the column width.
 Edit: 2022-06-08 To get an automatic recalculation use =CELL("WIDTH")+T(RAND()) 

[Tutorial] The SUMPRODUCT function

For either method, if you have specific sets of columns which you often want to show/hide, you can use recorded macros to perform those operations, and they can then either change the values in row 2 or trigger the forced recalculation of cell width. For example, if you have one set of columns for Team A and another set for Team B, you can record macros HideA, ShowA, HideB, and ShowB. If you have several different sets, you may want to record a macro for ShowAll. Or you could have HideAll and then select various sets for display. Using Tools → Customize you can put buttons for the macros on your own toolbar.
[Tutorial] Favorite Recorded Calc Macros

Zizi64 wrote: Tue May 31, 2022 7:00 am The function SUBTOTAL(109;range) works for rows when some rows are hidden.
As I understand it, SUBTOTAL() calculations are affected by Data → Filter, but not by Format → Row/Column → Hide/Show. Filters only apply to rows and so SUBTOTAL is not useful in this situation.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the subject field. Select the green checkmark icon at the same time.
Attachments
202205310914.ods
(16.43 KiB) Downloaded 107 times
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.5, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
eeigor
Posts: 214
Joined: Sun Apr 12, 2020 10:56 pm

Re: Do not include hidden cells in columns

Post by eeigor »

See AGGREGATE() with 2nd arg set to 5
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
User avatar
robleyd
Moderator
Posts: 5383
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Do not include hidden cells in columns

Post by robleyd »

eeigor wrote: Wed Jun 01, 2022 1:25 pm See AGGREGATE() with 2nd arg set to 5
Unfortunately that function is not available in AOO, only in LibreOffice.
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 25.2.31.2; SlackBuild for 25.2.3 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue]
Unexpected '{' on line 32
.
Post Reply