Variation on a SUMIF

ChrisCarrot

New Member
Joined
Jan 10, 2019
Messages
9
Does anyone know if it's possible to do something similar to a SUMIF, but on part of the Cell

For example, if I have a column of data, but each value is held in one cell. (eg ABC-1 is all in one cell).

ABC-1
ABC-2
CDE-3
ZTY-4
ABC-5

In the example above, i'd want to say "if the first three characters are "ABC", then add the last characters together. eg 1+2+5 = 8

I realise that i could do a text to columns to split across 2 columns then do a SUMIF, but trying to avoid that if possible.

Any advice would be very gratefully received. Thanks in advance.

Thank you
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try this:

=SUMPRODUCT(--(LEFT(A1:A5,3)="ABC"),--(MID(A1:A5,FIND("-",A1:A5)+1,99)))
 
Upvote 0
Wow! That was quick. I thought I was potentially asking the impossible.

I don't really understand how it works, but will try to get my head around it.

Thank you very much for such a quick response.
 
Upvote 0
Another way when number of characters before "-" is uneven

=SUMPRODUCT(--(MID(A1:A5,1,FIND("-",A1:A5)-1)="ABC")*MID(A1:A5,FIND("-",A1:A5)+1,255))
 
Upvote 0
Hi

=SUM(IF(LEFT(A1:A5,FIND("-",A1:A5)-1)=LEFT(A1,FIND("-",A1)-1),--RIGHT(A1:A5,LEN(A1:A5)-FIND("-",A1:A5)),0))
 
Upvote 0
Thank you for your help.

Just one further challenge..... if not all rows have data in, any idea how i could get it not to error on the total.

Eg

ABC-1
ABC-2
(intentional blank row)
CDE-3
ZTY-4
ABC-5

In the example above, i'd want to say "if the first three characters are "ABC", then add the last characters together. eg 1+2+5 = 8
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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