Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
eric
 
Posts: n/a
Default count # of instances in cell (a b a) answer 2 formula if possible

I can't get the count of the number of intances of a value to work.

ex: In single cell (a b a) answer=2 for "a", but does not work with any
formula I have tried.

=countif(data, "*"&text&"*") brings an answer of 0.

I was wondering if anyone knows how or if it is possbile to do this.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Marcelo
 
Posts: n/a
Default count # of instances in cell (a b a) answer 2 formula if possible

Hi Eric,

you could do using this module, press ALT+F11 copy it and paste.

___________________________________________
Function CountChar(MyChar, Mystring)
Dim counter As Integer

CountChar = 0

For counter = 1 To Len(Mystring)
If Mid(Mystring, counter, 1) = MyChar Then CountChar = CountChar + 1
Next counter

End Function
__________________________________

So the formula will be =countchar("a",E7)

does this help?
regards from Brazil
Marcelo



"eric" escreveu:

I can't get the count of the number of intances of a value to work.

ex: In single cell (a b a) answer=2 for "a", but does not work with any
formula I have tried.

=countif(data, "*"&text&"*") brings an answer of 0.

I was wondering if anyone knows how or if it is possbile to do this.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default count # of instances in cell (a b a) answer 2 formula if possible

=(LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),lower("a"),"")))/LEN("a")
Will count the number of A's or a's in A1.

If you want just the lower case a's:
=(LEN(A1)-LEN(SUBSTITUTE(A1,"a","")))/LEN("a")

eric wrote:

I can't get the count of the number of intances of a value to work.

ex: In single cell (a b a) answer=2 for "a", but does not work with any
formula I have tried.

=countif(data, "*"&text&"*") brings an answer of 0.

I was wondering if anyone knows how or if it is possbile to do this.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
eric
 
Posts: n/a
Default count # of instances in cell (a b a) answer 2 formula if possible

Thanks that worked.

Is there a way to get a total for a range of cells with the formula below?

"Dave Peterson" wrote:

=(LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),lower("a"),"")))/LEN("a")
Will count the number of A's or a's in A1.

If you want just the lower case a's:
=(LEN(A1)-LEN(SUBSTITUTE(A1,"a","")))/LEN("a")

eric wrote:

I can't get the count of the number of intances of a value to work.

ex: In single cell (a b a) answer=2 for "a", but does not work with any
formula I have tried.

=countif(data, "*"&text&"*") brings an answer of 0.

I was wondering if anyone knows how or if it is possbile to do this.


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default count # of instances in cell (a b a) answer 2 formula if possible

=(LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),lower("a"),"")))/LEN("a")

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"eric" wrote in message
...
Thanks that worked.

Is there a way to get a total for a range of cells with the formula below?

"Dave Peterson" wrote:

=(LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),lower("a"),"")))/LEN("a")
Will count the number of A's or a's in A1.

If you want just the lower case a's:
=(LEN(A1)-LEN(SUBSTITUTE(A1,"a","")))/LEN("a")

eric wrote:

I can't get the count of the number of intances of a value to work.

ex: In single cell (a b a) answer=2 for "a", but does not work with

any
formula I have tried.

=countif(data, "*"&text&"*") brings an answer of 0.

I was wondering if anyone knows how or if it is possbile to do this.


--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default count # of instances in cell (a b a) answer 2 formula if possible

Sorry, I meant

=SUMPRODUCT((LEN(A1:A10)-LEN(SUBSTITUTE(LOWER(A1:A10),LOWER("a"),"")))/LEN("
a"))

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"eric" wrote in message
...
Thanks that worked.

Is there a way to get a total for a range of cells with the formula below?

"Dave Peterson" wrote:

=(LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),lower("a"),"")))/LEN("a")
Will count the number of A's or a's in A1.

If you want just the lower case a's:
=(LEN(A1)-LEN(SUBSTITUTE(A1,"a","")))/LEN("a")

eric wrote:

I can't get the count of the number of intances of a value to work.

ex: In single cell (a b a) answer=2 for "a", but does not work with

any
formula I have tried.

=countif(data, "*"&text&"*") brings an answer of 0.

I was wondering if anyone knows how or if it is possbile to do this.


--

Dave Peterson



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
eric
 
Posts: n/a
Default count # of instances in cell (a b a) answer 2 formula if possi

Great, that worked perfect. Thanks to everyone

"Bob Phillips" wrote:

Sorry, I meant

=SUMPRODUCT((LEN(A1:A10)-LEN(SUBSTITUTE(LOWER(A1:A10),LOWER("a"),"")))/LEN("
a"))

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"eric" wrote in message
...
Thanks that worked.

Is there a way to get a total for a range of cells with the formula below?

"Dave Peterson" wrote:

=(LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),lower("a"),"")))/LEN("a")
Will count the number of A's or a's in A1.

If you want just the lower case a's:
=(LEN(A1)-LEN(SUBSTITUTE(A1,"a","")))/LEN("a")

eric wrote:

I can't get the count of the number of intances of a value to work.

ex: In single cell (a b a) answer=2 for "a", but does not work with

any
formula I have tried.

=countif(data, "*"&text&"*") brings an answer of 0.

I was wondering if anyone knows how or if it is possbile to do this.

--

Dave Peterson




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel: Allow combination of formula answer and text in one cell wood nerd Excel Worksheet Functions 3 May 4th 06 01:07 AM
Custom functions calculating time arguments Help Desperate Bill_De Excel Worksheet Functions 12 April 25th 06 02:22 AM
Formula to count Cell colour. themax16 Excel Discussion (Misc queries) 3 May 29th 05 01:41 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM
Formula window displays correct answer while cell displays incorre MMV Excel Worksheet Functions 3 November 10th 04 09:28 PM


All times are GMT +1. The time now is 11:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"