SOLVED

Array formulas and spilling

%3CLINGO-SUB%20id%3D%22lingo-sub-2512386%22%20slang%3D%22en-US%22%3EArray%20formulas%20and%20spilling%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2512386%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20there%20a%20way%20to%20test%20for%20a%20value%20in%20a%20range%20of%20cells%20and%20then%2C%20if%20some%20of%20the%20cells%20are%20not%20empty%2C%20send%20the%20sum%20of%20the%20non-empty%20cells%20to%20another%20single%20cell%3F%20I%20have%20been%20experimenting%20with%20formulas%20to%20accomplish%20this%20but%20always%20end%20up%20with%20a%20%22Spill.%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2512386%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2512424%22%20slang%3D%22en-US%22%3ERe%3A%20Array%20formulas%20and%20spilling%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2512424%22%20slang%3D%22en-US%22%3EGiving%20more%20detailed%20examples%20and%20better%20yet%20a%20sample%20spreadsheet%20helps%20a%20lot.%20I'm%20really%20not%20sure%20I%20understand%20what%20you%20are%20asking%20for%20but%20will%20give%20it%20a%20shot.%3CBR%20%2F%3EFirst%20off%2C%20your%20first%20part%20is%20to%20check%20for%20a%20particular%20value%20in%20a%20range%20of%20cells%20and%20then%20you%20say%20IF%20some%20are%20not%20empty%2C%20which%20has%20to%20be%20the%20case%20if%20you%20found%20that%20value%20then%20at%20least%201%20is%20not%20empty%2C%20right%3F%20Unless%20that%20value%20is%20a%20text%20value%20in%20which%20case%20it%20is%20'empty'%20w%2Fr%20to%20a%20sum.%3CBR%20%2F%3ENext%20you%20say%20you%20are%20getting%20%22Spill%22%20error%20which%20indicates%20you%20are%20getting%20an%20array%20of%20values%20back%20(instead%20of%20a%20single%20value)%20but%20there%20is%20already%20data%20in%20the%20cell(s)%20nearby%20that%20would%20be%20required%20to%20show%20that%20array%20of%20data.%3CBR%20%2F%3ELastly%2C%20you%20say%20%22send%20the%20sum%20..%20to%20another%20single%20cell%22%20but%20Excel%20does%20NOT%20work%20like%20that.%20A%20formula%20in%20an%20Excel%20cell%20defines%20what%20value%20to%20show%20in%20that%20cell%20(not%20counting%20the%20spill%20over%20due%20to%20returning%20arrays).%3CBR%20%2F%3EIn%20any%20case%20here%20is%20what%20I%20think%20you%20are%20asking%3A%3CBR%20%2F%3E%3DIFERROR(IF(MATCH(V1%2CR1%3AR5%2C0)%2CSUM(R1%3AR5)%2C%22%22)%2C%22%22)%3CBR%20%2F%3Ewhere%20V1%20is%20the%20value%20you%20are%20looking%20for%20and%20R1%3AR5%20is%20the%20Range%20of%20cells.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2513298%22%20slang%3D%22en-US%22%3ERe%3A%20Array%20formulas%20and%20spilling%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2513298%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F64084%22%20target%3D%22_blank%22%3E%40David%20Lambert%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20variant%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(ISNA(XMATCH(%2CA1%3AA20))%2C%20%22no%20blank%20cells%22%2C%20SUM(A1%3AA20))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eif%20you%20mean%20blank%20cells%2C%20not%20cells%20with%20empty%20string%20%22%22.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2513213%22%20slang%3D%22en-US%22%3ERe%3A%20Array%20formulas%20and%20spilling%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2513213%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F64084%22%20target%3D%22_blank%22%3E%40David%20Lambert%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E...sum%20of%20the%20%3CU%3Enon-empty%3C%2FU%3E%20cells%20to%20another%20single%20cell%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Demo.png%22%20style%3D%22width%3A%20148px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F293262iD1C8953533EB7093%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Demo.png%22%20alt%3D%22Demo.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Ein%26nbsp%3B%3CSTRONG%3EC1%3C%2FSTRONG%3E%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMIF(A1%3AA8%2C%22%26lt%3B%26gt%3B%22%2CA1%3AA8)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EThat%20would%20work%20even%20if%20empty%20cells%20contain%20something%20like%3A%26nbsp%3B%3CSTRONG%3E%3D%22%22%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2513634%22%20slang%3D%22en-US%22%3ERe%3A%20Array%20formulas%20and%20spilling%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2513634%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20works%20too.%20Thank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2513635%22%20slang%3D%22en-US%22%3ERe%3A%20Array%20formulas%20and%20spilling%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2513635%22%20slang%3D%22en-US%22%3E%3CP%3EPerfect!%20Does%20exactly%20what%20I%20want%20it%20to%20do.%20This%20works%20with%20the%20'Average'%20function%20as%20well.%20Thank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Is there a way to test for a value in a range of cells and then, if some of the cells are not empty, send the sum of the non-empty cells to another single cell? I have been experimenting with formulas to accomplish this but always end up with a "Spill."

8 Replies
Giving more detailed examples and better yet a sample spreadsheet helps a lot. I'm really not sure I understand what you are asking for but will give it a shot.
First off, your first part is to check for a particular value in a range of cells and then you say IF some are not empty, which has to be the case if you found that value then at least 1 is not empty, right? Unless that value is a text value in which case it is 'empty' w/r to a sum.
Next you say you are getting "Spill" error which indicates you are getting an array of values back (instead of a single value) but there is already data in the cell(s) nearby that would be required to show that array of data.
Lastly, you say "send the sum .. to another single cell" but Excel does NOT work like that. A formula in an Excel cell defines what value to show in that cell (not counting the spill over due to returning arrays).
In any case here is what I think you are asking:
=IFERROR(IF(MATCH(V1,R1:R5,0),SUM(R1:R5),""),"")
where V1 is the value you are looking for and R1:R5 is the Range of cells.
best response confirmed by David Lambert (Occasional Contributor)
Solution

@David Lambert 

...sum of the non-empty cells to another single cell

Demo.png

in C1:

 

=SUMIF(A1:A8,"<>",A1:A8)

That would work even if empty cells contain something like: =""

 

@David Lambert 

As variant

=IF(ISNA(XMATCH(,A1:A20)), "no blank cells", SUM(A1:A20))

if you mean blank cells, not cells with empty string "".

This works too. Thank you.

Perfect! Does exactly what I want it to do. This works with the 'Average' function as well. Thank you.

@David Lambert 

Well, this produces the same result:

=SUM(A1:A8)

@David Lambert 

Perhaps I misunderstood the question: to sum only if there are no blank cells in the range, if at least one blank cell then return something else.

Otherwise that's as @Detlef Lewin suggested.

@David Lambert 

If this works as you expect I probably misunderstood something as well => Use Detlef's one:

=SUM(A1:A8)


Same goes with Average

=AVERAGE(A1:A8)

 

Could you unmark the current Best response and mark the one from Detlef instead please?

Thanks & nice day...