count formula 3s&1s

andrichara

New Member
hi to all, i have an arrey formula at H1 which counts 3s and 1s only from a row G:G(random generator of 3s,2s,1s) and in case of number 2 apeared should count 0 and then continue counting 3s and 1s.
the formula is working until 2 apears ,it shows 0zero but it stops, imean the zero is permanent,i want the formula to continue counting.

=IF(COUNTIFS(G:G,"<>1",G:G,"<>3",G:G,"<>")<>0,0,IFERROR(INT(MATCH(0,INDEX(--(\$G2:INDEX(G:G,COUNT(G:G))<>\$G1:INDEX(G:G,COUNT(G:G)-1)),N(IF(1,COUNT(G:G)-ROW(INDIRECT("1:"&COUNT(G:G)-1))))),)/2),INT(COUNT(G:G)/2)))

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Are you just counting 1s and 3s because that is a lot of formula for just that.

Excel 2010
GH
133
22
31
43
Sheet1
Cell Formulas
RangeFormula
H1=SUM(COUNTIF(G:G,{1,3}))

Last edited:
If you mean a running count, then try this:

=SUM(COUNTIF(\$G\$1:G1,{1,3}))*(G1<>2)
Copy down.

Excel 2010
GH
131
220
312
433
Sheet1
Cell Formulas
RangeFormula
H1=SUM(COUNTIF(\$G\$1:G1,{1,3}))*(G1<>2)
H2=SUM(COUNTIF(\$G\$1:G2,{1,3}))*(G2<>2)
H3=SUM(COUNTIF(\$G\$1:G3,{1,3}))*(G3<>2)
H4=SUM(COUNTIF(\$G\$1:G4,{1,3}))*(G4<>2)

Last edited:
If you mean a running count, then try this:

=SUM(COUNTIF(\$G\$1:G1,{1,3}))*(G1<>2)
Copy down.

Excel 2010
GH
131
220
312
433

</tbody>
Sheet1

Worksheet Formulas
CellFormula
H1=SUM(COUNTIF(\$G\$1:G1,{1,3}))*(G1<>2)
H2=SUM(COUNTIF(\$G\$1:G2,{1,3}))*(G2<>2)
H3=SUM(COUNTIF(\$G\$1:G3,{1,3}))*(G3<>2)
H4=SUM(COUNTIF(\$G\$1:G4,{1,3}))*(G4<>2)

</tbody>

<tbody>
</tbody>
thank you so much

the formula is counting an event ,like if 31 count1 if then 313count 1 if then3131 count 2 and so on,what i need is if any other number apeared except 3 and 1 to count 0 and if then continue if 3 1 apeared

So did this work for you?

Cross posted https://www.excelforum.com/excel-general/1262572-count-if-formula.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

So did this work for you?

thanks Huish!!super! is what i needed!sorry for my delay reply

Replies
3
Views
161
Replies
3
Views
274
Replies
0
Views
121
Replies
2
Views
131
Replies
6
Views
667

1,203,507
Messages
6,055,809
Members
444,826
Latest member
aggerdanny

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.

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

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