count number of same characters in a string

anzer

Board Regular
Joined
Mar 5, 2015
Messages
67
Hello,

I'm quiting smoking after 10 years! (I'm 25 and it's been 5 days in a row now!! )
and to help me I created an excel file with a calendar
When I smoke I put F below the date and X if I don't smoke. I want a formulas that count the number of X in a row example:

F F X F F X F X X X X X ( each letter are in a different cell and I want the result to be 5 not 7 )

Any idea ?! :)

Thank you
 
I will leave a note at the end of the year and answer this thread to keep you posted :) Thank you a million time once again!
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Eric's Method showed me using array's gets around the need of a helper row. I really need to get better with arrays.
Here is an example of how I typically do it without arrays.

With C10:AY10 having data of
FFXFFXFXXXXX

<tbody>
</tbody>

In C11 and run it across to AY11
Code:
=IF(C$10="X",B$11+1,0)

Total Days not smoking, anywhere on the sheet
Code:
=COUNTIF($C$10:$AY$10,"X")

Max consecutive days not smoking, anywhere on the sheet
Code:
=MAX($C$11:$AY$11)
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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