Count cells in one column if they do or do not start with a text in another column.

JeffFinnan

New Member
Joined
Aug 12, 2020
Messages
47
Office Version
  1. 2019
Platform
  1. Windows
I am trying to find a way to add up numbers in one column if the numbers meet the criterium that a text cell in another column does not start with "-". The cells in the other column could be -TTWO230120C115, SWKS, NYT, -NYT220121C55, etc. I want to count cell that contain SWKS and NYT in another column, but not -TTWO230120C115 and -NYT220121C55.

I tried =SUMIF(C2:C103,"<>-*",I2:I103) and all cells were counted. If I tried =SUMIF(C2:C103,"-*",I2:I103), no cells were counted. If I used =SUMIFS(I2:I103,C2:C103,"-*"), got 0 and if "<>-*" in that formula, got all numbers added.

Now my work around was in a separate column use =IF(LEFT(TRIM(C2),1)="-",0,I2) and copy down and then sum that new column. Is there a way to not have to set up a separate column?

Thanks,
Jeff
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Check that you don't have a space before the - sign. As
Excel Formula:
=SUMIFS(I2:I103,C2:C103,"<>-*")
should work.
 
Upvote 0
Did you check to ensure there were no leading spaces (or other characters) in the data?
 
Upvote 0
Did you check to ensure there were no leading spaces (or other characters) in the data?
Yes. Please note that =IF(LEFT(TRIM(C2),1)="-",0,I2) properly detects whether the "-" sign is there or not and gives the correct response, 0 or values depending on the presence or absence of the sign.

Thanks,
Jeff
 
Upvote 0
That suggests that you do have one (or more) spaces before the - sign.
What does
Excel Formula:
=IF(LEFT(C2,1)="-",0,I2)
return?
 
Upvote 0
That suggests that you do have one (or more) spaces before the - sign.
What does
Excel Formula:
=IF(LEFT(C2,1)="-",0,I2)
return?
Yeah, it reports all values. I went back and realized that I did not understand what you said about spaces. If I use
Excel Formula:
=SUMIFS(I2:I103,C2:C103,"<> -*")
with that space before the sign. It works. So problem solved. Sorry about my misunderstanding.

Thanks,
Jeff
 
Upvote 0
Solution
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

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