Count if formula

Brew

Well-known Member
Joined
Sep 29, 2003
Messages
1,569
How do I create a formula that counts the N and the following Y in the list and if not then x.

example
T4:T13 = N,N,N,N,N,N,N,Y,Y,Y
formula Result
U4:U13 = 1,2,3,4,5,6,7,8,9,x,x
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,705
Is this what you mean?

U4, copied down:

=IF(OR(T4={"N","Y"}),SUM(COUNTIF(T$4:T4,{"N","Y"})),"X")
 

Dufus

Board Regular
Joined
Aug 19, 2006
Messages
176
Does this work?
=IF(AND(T3="N",T4="Y"),COUNTA($T$4:T4),IF(T4="N",COUNTA($T$4:T4),"X"))

Dufus
 

Brew

Well-known Member
Joined
Sep 29, 2003
Messages
1,569
Domenic, your formula, just does a continous numerical count of all records.
Dufus, your formula counts correctly, however, after x, when another N record appears, then recount. see expanded example.

example
T4:T15 = N,N,N,N,N,N,N,Y,Y,Y,N,N
formula Result
U4:U15 = 1,2,3,4,5,6,7,8,9,x,x,1,2
thanks
 

Brew

Well-known Member
Joined
Sep 29, 2003
Messages
1,569

ADVERTISEMENT

I need the formula to do execute like the following example:
example
T4:T18 = N,N,N,N,N,N,N,Y,Y,Y,N,N,Y,Y,N
formula Result
U4:U18 = 1,2,3,4,5,6,7,8,9,x,x,1,2,3,x,1
 

Brew

Well-known Member
Joined
Sep 29, 2003
Messages
1,569
Does anyone know if code would be more efficient for this problem
 

bosco_yip

Well-known Member
Joined
Dec 2, 2002
Messages
1,938
Office Version
  1. 2019
Platform
  1. Windows
Does this help ?

U4 =IF(T4="Y","x",IF((T4="N")*(T3="Y"),1,U3+1))

Regards
Bosco
 

Forum statistics

Threads
1,137,335
Messages
5,680,893
Members
419,937
Latest member
Talic

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
Top