Link to home
Start Free TrialLog in
Avatar of hindersaliva
hindersalivaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Excel - nested formulas problem

Doesn't Trim work within formulas?

I got a SUMIF like this
=SUMIF($A$18:$A$1006,A2,D$18:D$1006)

It looks like some of the text in the range $A$18:$A$1006 have trailing zeros! So they are not included in the SUMIF.
I tried this, but it doesn't like it
=SUMIF(Trim($A$18:$A$1006),A2,D$18:D$1006)

Why???? Isn't that just a nested formula?

Thanks
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

You cannot manipulate the range passed inside a SUMIF formula. You may try SUMPRODUCT instead for that purpose.
=SUMPRODUCT((TRIM($A$18:$A$1006)=A2)*(D$18:D$1006))

Open in new window

Avatar of hindersaliva

ASKER

I don't get it. Why can we put a Trim in a SUMPRODUCT, but not a SUMIF?
Is my syntax incorrect?
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You might be able to use a wild card on the A2 value:

=SUMIF($A$18:$A$1006,A2&"*",D$18:D$1006)

That will sumif anything that starts the same as A2
Rob, that's useful to know. And it might have worked in this case. But I notice that some of the criteria has other characters following (and not just a space).
Thanks Subodh.
Thanks for the feedback and bonus points.

BTW TRIM function will only remove leading spaces, multiple spaces within text (leaving single space) and trailing spaces; not trailing zeros as per question. TRIM will also not deal with other non-printing characters, CLEAN function will deal with some but again not all.
You're welcome!
Oops, sorry Rob! In the question I meant trailing spaces!