counting in sequence of appearance of a string on a column

Abdmujib

Board Regular
Joined
May 15, 2022
Messages
88
Office Version
  1. 365
Platform
  1. Windows
I have a column B, which has a string of "yes" and "No". I want to find a way to number in sequence on column C, where Yes appears. when "No" occurs it should leave a blank space and start all over from 1 for appearance of "Yes. I want for "No" on column C

attached is the picture of how i want it to be.
 

Attachments

  • Yes no.JPG
    Yes no.JPG
    27 KB · Views: 10

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi Abdmujib,

Assuming the Yes/No flags are in the range B3:B17 try these formulas in the initial cell stated and then copy them down to Row 17:

Cell C3 =IF(B3<>"Yes","",IF(B2="Yes",C2+1,1))
Cell D3 =IF(B3<>"No","",IF(B2="No",D2+1,1))

I think your image is out as there's there's two No's about half way down but only the first is flagged.

Regards,

Robert
 
Upvote 1
Check this and revert -

Book1
ABC
1If Yesif No
2Yes1 
3No 1
4Yes1 
5Yes2 
6Yes3 
7No 1
8No  
9Yes1 
10No 1
11Yes1 
12No 1
13No 2
14No 3
15No 4
16No 5
Sheet1
Cell Formulas
RangeFormula
B2:B16B2=IFS(AND(A2="Yes",OR(A1="No",A1="")),1,AND(A2="Yes",A1="Yes"),B1+1,TRUE,"")
C2:C16C2=IFS(AND(A2="No",A1="Yes"),1,AND(A2="No",A1="No",OR(A3="No",A3="")),C1+1,TRUE,"")
 
Upvote 1
Solution
Since you are using XL365, you could put this single formula in cell C3 (do not copy it down) and let it spill all of the "Yes" sequence counts...

=SCAN("",B3:B17,LAMBDA(a,x,IF(x="Yes",(0&a)+1,"")))

For the "No" sequence counts, put this single formula in cell D3 (do not copy it down)...

=SCAN("",B3:B17,LAMBDA(a,x,IF(x="No",(0&a)+1,"")))

Change the B3:B17 in each formula to match your actual range containing your "Yes" and "No" values.
 
Upvote 1
Since you are using XL365, you could put this single formula in cell C3 (do not copy it down) and let it spill all of the "Yes" sequence counts...

=SCAN("",B3:B17,LAMBDA(a,x,IF(x="Yes",(0&a)+1,"")))

For the "No" sequence counts, put this single formula in cell D3 (do not copy it down)...

=SCAN("",B3:B17,LAMBDA(a,x,IF(x="No",(0&a)+1,"")))

Change the B3:B17 in each formula to match your actual range containing your "Yes" and "No" values.
@Rick Rothstein
I was looking for something like this, and you found it and it worked, but why is it that a few moments later the formula becomes
Excel Formula:
#Value
 
Upvote 0
@Rick Rothstein
I was looking for something like this, and you found it and it worked, but why is it that a few moments later the formula becomes
Excel Formula:
#Value
What do you mean "later the formula becomes #Value? As far as I know, that cannot happen on its own. What did you do between the time the formula was placed in the cell and when the error appeared? If nothing, do you have any VBA code, specifically event code, running in the workbook?
 
Upvote 0
What do you mean "later the formula becomes #Value? As far as I know, that cannot happen on its own. What did you do between the time the formula was placed in the cell and when the error appeared? If nothing, do you have any VBA code, specifically event code, running in the workbook?
I mean when I copy the formula, it works in a moment, but a few minutes later it becomes value
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

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