COUNTIF problem

IneedHel

New Member
Joined
Jul 27, 2017
Messages
14
How do use the countif or another formula to count the first digit that is followed by text?

This is the formula I tried but it didn't work: =COUNTIF(C77:I77,"1-pri*")

What I need is to total up the first digit in a cell range .

Example: A1,A2,A3 = 8

cellA1 cellA2 cellA3 cellA4
1-pri5 5-pri1 2-pri3 8
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
how do use the countif or another formula to count the first digit that is followed by text?

This is the formula i tried but it didn't work: =countif(c77:i77,"1-pri*")

what i need is to total up the first digit in a cell range .

Example: A1,a2,a3 = 8

cella1 cella2 cella3 cella4
1-pri5 5-pri1 2-pri3 8

=sumproduct(--(left(a1:a14,1)="8"))

Left(A1,1) returns the first value.
if Left(A1,1)=8, excel will return "True"
-True= -1
--True = 1
 
Last edited:
Upvote 0
Close. Leave out the condition to get the Sum.

=SUMPRODUCT(--LEFT(C77:I77,1))

This will sum the first character of every cell in the specified range.
 
Upvote 0
Hi,

Zack's formula should work, if you're getting #VALUE error, you may have leading spaces, try this, it will also SUM single or multiple leading digits (Don't forget to change cell references to suit your data):


Book1
A
11-pri1
22-pri5
33-pri2
41-pri1
51-pri1
6
78
Sheet11
Cell Formulas
RangeFormula
A7=SUMPRODUCT(--LEFT(A1:A5,FIND("-",A1:A5)-1))
 
Upvote 0
Good point jtakw. If leading/trailing spaces is a problem, I'd recommend removing them, as opposed to using formula to work around it, and just solve the problem at the root of it.
 
Upvote 0

Forum statistics

Threads
1,224,830
Messages
6,181,228
Members
453,025
Latest member
Hannah_Pham93

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