Troubles with SUMPRODUCT and text to value

tohegut

New Member
Joined
Oct 27, 2017
Messages
5
Hi, thanks for all the help here!

I have a row that can contain cells with values of 'ABC1', 'ABC2', ... 'ABC9', and also blank.
(This row also contains integer values, I want to ignore these)

I want to sum up all the ABCX numbers, so if I have in Row 1:
ABC1 ABC1 ABC7
To sum up, this is easy with:
=SUMPRODUCT(--(LEFT(A1:C1,3)="ABC"),VALUE(RIGHT(A1:C1)))
and my result will be 9.

BUT! This formula does not work if there is a blank in the range, or some text.
I get a #VALUE error and I'm not sure how to fix it.
The problem must be because blanks and pure text can't be treated as a VALUE(), but I need to use this function to treat the number I extract from ABCX as a number.

Thanks for your time :)
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi,

TRy this : Ctrl +Shift+Enter not just Enter

=SUMPRODUCT(--(LEFT(A1:D1,3)="ABC"),VALUE(IFERROR(RIGHT(A1:D1)*1,0)))
 
Upvote 0
=SUMPRODUCT(--(LEFT(A1:D1,3)="ABC"),VALUE(IFERROR(RIGHT(A1:D1)*1,0)))

This takes the rightmost character of a cell and multiplies by 1, if there's an error it uses 0.
Why do we multiply by 1?
And why is a array formula necessary?

I think we multiply by 1 so that, if it's not a number, we get an error before we try to convert it using VALUE().
I have used array formula before but sometimes I not sure when best to use them.

Thanks again for helping me with this.
 
Upvote 0
=SUMPRODUCT(--(LEFT(A1:D1,3)="ABC"),VALUE(IFERROR(RIGHT(A1:D1)*1,0)))

This takes the rightmost character of a cell and multiplies by 1, if there's an error it uses 0.
Why do we multiply by 1?
And why is a array formula necessary?

I think we multiply by 1 so that, if it's not a number, we get an error before we try to convert it using VALUE().
I have used array formula before but sometimes I not sure when best to use them.

Thanks again for helping me with this.

In this case we use an array formula because left and right functions are delivering arrays results whereas they are intend to deliver a single result only.

Take a look at Mike 'ExcelIsFun' Girvin youtube channel and/or read his book CTRL+SHIFT+ENTER for further explanations.

Vandalo
 
Upvote 0
Either just enter:

=SUMPRODUCT(SUBSTITUTE(UPPER(0&A1:D1),"ABC",0)+0)

or control+shift+enter, not just enter:

=SUM(IF(ISNUMBER(SEARCH("ABC",A1:D1)),SUBSTITUTE(UPPER(A1:D1),"ABC","")+0))
 
Upvote 0
Thanks for the help everyone.
or control+shift+enter, not just enter:
=SUM(IF(ISNUMBER(SEARCH("ABC",A1:D1)),SUBSTITUTE(UPPER(A1:D1),"ABC","")+0))
this is the nicest one I think, I was limiting myself by using RIGHT() because it would not support numbers like ABC0.5
This method works fine. Thank you.
 
Upvote 0

Forum statistics

Threads
1,216,171
Messages
6,129,279
Members
449,498
Latest member
Lee_ray

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