ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to count the number of occurrence within string? (https://www.excelbanter.com/excel-discussion-misc-queries/206003-how-count-number-occurrence-within-string.html)

Eric

How to count the number of occurrence within string?
 
Does anyone have any suggestions on how to count the number of occurrence
within string? For example, aa11bb5c in cell A1, and "a" in cell B1, I would
like to count the number of occurrence for the char "a" in cell B1 within
string "aa11bb5c" in cell A1, and return the number of occurrence 2 in cell
c1.
Does anyone have any suggestions?
Thanks in advance for any suggestions
Eric

muddan madhu

How to count the number of occurrence within string?
 
try this

put this formula in C1 =SUM((MID(A1,COLUMN(1:1),1)=B1)*1)

use ctrl + shift + enter





On Oct 12, 12:17*pm, Eric wrote:
Does anyone have any suggestions on how to count the number of occurrence
within string? For example, aa11bb5c in cell A1, and "a" in cell B1, I would
like to count the number of occurrence for the char "a" in cell B1 within
string "aa11bb5c" in cell A1, and return the number of occurrence 2 in cell
c1.
Does anyone have any suggestions?
Thanks in advance for any suggestions
Eric



Rick Rothstein

How to count the number of occurrence within string?
 
Try this in C1...

=LEN(A1)-LEN(SUBSTITUTE(A1,B1,""))

--
Rick (MVP - Excel)


"Eric" wrote in message
...
Does anyone have any suggestions on how to count the number of occurrence
within string? For example, aa11bb5c in cell A1, and "a" in cell B1, I
would
like to count the number of occurrence for the char "a" in cell B1 within
string "aa11bb5c" in cell A1, and return the number of occurrence 2 in
cell
c1.
Does anyone have any suggestions?
Thanks in advance for any suggestions
Eric




All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com