Sum cells, ignoring hidden columns

sofas

Well-known Member
Joined
Sep 11, 2022
Messages
559
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
How can I calculate the sum of the following cells while ignoring the hidden columns?

=SUBTOTAL(109,E4,G4,I4,K4,M4,O4,Q4,S4)
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Can you please post your data here.

Thanks
 
Upvote 0
I am sorry, not the link, i mean pasting your data here, thanks
 
Upvote 0
N.B. My suggestion does not consider the "hidden" part of the question.
It gives the sum whether of not the columns are hidden.

With Excel 365 and possibly 2021, try the following.
With earlier versions of Excel, use SumProduct.
Does your data include Headings?

T202401a.xlsm
EGIKMOQSTU
426101418222630128128
1a
Cell Formulas
RangeFormula
T4T4=SUM(E4:S4*(--ISODD(COLUMN(E4:S4))))
U4U4=SUM(E4:S4*({1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}))
 
Last edited:
Upvote 0
I haven't tested the Lambda

T202401a.xlsm
EGIKMOQSTU
726101418222630128128
8
1a
Cell Formulas
RangeFormula
T7T7=SUM(IF(CELL("width",OFFSET(E7:S7,,SEQUENCE(,COLUMNS(E7:S7),0))),E7:S7))
U7U7=SumNotHiddenColumn(E7:S7)
Lambda Functions
NameFormula
SumNotHiddenColumn=LAMBDA(rColsHidden,LET(rH,rColsHidden,SUM(IF(CELL("width",OFFSET(rH,,SEQUENCE(,COLUMNS(rH),0))),rH))))
 
Last edited:
Upvote 0
For earlier versions of Excel, try the following.
I do not know if the formula works with Excel 2019.
The Lambda suggestion requires Excel 365.
T202401a.xlsm
EGIKMOQSTU
426101418222630128128
1a
Cell Formulas
RangeFormula
T4T4=SUMPRODUCT(E4:S4,--ISODD(COLUMN(E4:S4)))
U4U4=SUMPRODUCT(E4:S4*({1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}))
 
Last edited:
Upvote 0
If columns are hidden or unhidden, we must force a recalculation to secure the correct result. Use F9.

T202401a.xlsm
EFGTUVW
3OddOdd
4123646466
5
1a
Cell Formulas
RangeFormula
T4T4=SUMPRODUCT(E4:S4,--ISODD(COLUMN(E4:S4)))
U4U4=SUMPRODUCT(E4:S4*({1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}))
V4V4=LET(rng,E4:S4,SUM(--(CELL("width",OFFSET(rng,,SEQUENCE(,COLUMNS(rng),0)))>0)*rng))
W4W4=SumNot(E4:S4)
Lambda Functions
NameFormula
SumNot=LAMBDA(rngColumns,LET(rCols,rngColumns,SUM(--(CELL("width",OFFSET(rCols,,SEQUENCE(,COLUMNS(rCols),0)))>0)*rCols)))


T202401a.xlsm
EFGHIJKLMNOPQRSTUVW
3OddOdd
41234567891011121314156464120120
1a
Cell Formulas
RangeFormula
T4T4=SUMPRODUCT(E4:S4,--ISODD(COLUMN(E4:S4)))
U4U4=SUMPRODUCT(E4:S4*({1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}))
V4V4=LET(rng,E4:S4,SUM(--(CELL("width",OFFSET(rng,,SEQUENCE(,COLUMNS(rng),0)))>0)*rng))
W4W4=SumNot(E4:S4)
Lambda Functions
NameFormula
SumNot=LAMBDA(rngColumns,LET(rCols,rngColumns,SUM(--(CELL("width",OFFSET(rCols,,SEQUENCE(,COLUMNS(rCols),0)))>0)*rCols)))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top