Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 989
Default counting entries within a cell's formula

I am interested in doing a count of entries within a cell. It would be
similar to a word count, but instead of counting words, I need to count the
plus signs (+) or something like that. I have a simple formula in the cell
like:

=100+1235+3456+0987+etc

and am only interested in determining how many entries are in there since
each number entry represents a program and I would like to know how many
programs are accounted for.

I've tried this variation on the word wount, but no success:

=IF(LEN(TRIM(B4))=0,0,LEN(TRIM(B4))-LEN(SUBSTITUTE(B4,CHAR(43)," "))+1)
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
bj bj is offline
external usenet poster
 
Posts: 1,397
Default counting entries within a cell's formula

your equation is ok except chnge " " to ""
a space counts as one character.

"Mark" wrote:

I am interested in doing a count of entries within a cell. It would be
similar to a word count, but instead of counting words, I need to count the
plus signs (+) or something like that. I have a simple formula in the cell
like:

=100+1235+3456+0987+etc

and am only interested in determining how many entries are in there since
each number entry represents a program and I would like to know how many
programs are accounted for.

I've tried this variation on the word wount, but no success:

=IF(LEN(TRIM(B4))=0,0,LEN(TRIM(B4))-LEN(SUBSTITUTE(B4,CHAR(43)," "))+1)

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default counting entries within a cell's formula

thsi custom function will count plus signs. The number of words is one more
than the plus signs

Function CountPlus(Mycell As Range)

MyString = Mycell.Formula
CountPlus = 0
For i = 1 To Len(MyString)

If StrComp("+", Mid(MyString, i, 1)) = 0 Then
CountPlus = CountPlus + 1
End If

Next i


End Function


"Mark" wrote:

I am interested in doing a count of entries within a cell. It would be
similar to a word count, but instead of counting words, I need to count the
plus signs (+) or something like that. I have a simple formula in the cell
like:

=100+1235+3456+0987+etc

and am only interested in determining how many entries are in there since
each number entry represents a program and I would like to know how many
programs are accounted for.

I've tried this variation on the word wount, but no success:

=IF(LEN(TRIM(B4))=0,0,LEN(TRIM(B4))-LEN(SUBSTITUTE(B4,CHAR(43)," "))+1)

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 989
Default counting entries within a cell's formula

I've done my share of heavy Excel programming, but am a bit lost as to how
you would write this into a functional formula. Can you please elaborate on
how to create this custom function? Thanks

"Joel" wrote:

thsi custom function will count plus signs. The number of words is one more
than the plus signs

Function CountPlus(Mycell As Range)

MyString = Mycell.Formula
CountPlus = 0
For i = 1 To Len(MyString)

If StrComp("+", Mid(MyString, i, 1)) = 0 Then
CountPlus = CountPlus + 1
End If

Next i


End Function


"Mark" wrote:

I am interested in doing a count of entries within a cell. It would be
similar to a word count, but instead of counting words, I need to count the
plus signs (+) or something like that. I have a simple formula in the cell
like:

=100+1235+3456+0987+etc

and am only interested in determining how many entries are in there since
each number entry represents a program and I would like to know how many
programs are accounted for.

I've tried this variation on the word wount, but no success:

=IF(LEN(TRIM(B4))=0,0,LEN(TRIM(B4))-LEN(SUBSTITUTE(B4,CHAR(43)," "))+1)

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default counting entries within a cell's formula

I don't know if my previous reply got posted.
It is easy to use this function.

1) go to the tab on the bottom of the worksheet (normally sheet1) and right
click. Select view code
2) Go to VBA Menu and select insert Module. a new module 1 will be shown.

3) Paste code from Function to End Function.
4) Remove the that this website inserts.
5) You are done.


Use this function like any other function

=CountPlus(A3)

A3 will have a formula like =A1+A2


"Mark" wrote:

I've done my share of heavy Excel programming, but am a bit lost as to how
you would write this into a functional formula. Can you please elaborate on
how to create this custom function? Thanks

"Joel" wrote:

thsi custom function will count plus signs. The number of words is one more
than the plus signs

Function CountPlus(Mycell As Range)

MyString = Mycell.Formula
CountPlus = 0
For i = 1 To Len(MyString)

If StrComp("+", Mid(MyString, i, 1)) = 0 Then
CountPlus = CountPlus + 1
End If

Next i


End Function


"Mark" wrote:

I am interested in doing a count of entries within a cell. It would be
similar to a word count, but instead of counting words, I need to count the
plus signs (+) or something like that. I have a simple formula in the cell
like:

=100+1235+3456+0987+etc

and am only interested in determining how many entries are in there since
each number entry represents a program and I would like to know how many
programs are accounted for.

I've tried this variation on the word wount, but no success:

=IF(LEN(TRIM(B4))=0,0,LEN(TRIM(B4))-LEN(SUBSTITUTE(B4,CHAR(43)," "))+1)



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 989
Default counting entries within a cell's formula

cool, it works great, thanks for the help! And now I understand how to ad
some new custom functionality too!

"Joel" wrote:

I don't know if my previous reply got posted.
It is easy to use this function.

1) go to the tab on the bottom of the worksheet (normally sheet1) and right
click. Select view code
2) Go to VBA Menu and select insert Module. a new module 1 will be shown.

3) Paste code from Function to End Function.
4) Remove the that this website inserts.
5) You are done.


Use this function like any other function

=CountPlus(A3)

A3 will have a formula like =A1+A2


"Mark" wrote:

I've done my share of heavy Excel programming, but am a bit lost as to how
you would write this into a functional formula. Can you please elaborate on
how to create this custom function? Thanks

"Joel" wrote:

thsi custom function will count plus signs. The number of words is one more
than the plus signs

Function CountPlus(Mycell As Range)

MyString = Mycell.Formula
CountPlus = 0
For i = 1 To Len(MyString)

If StrComp("+", Mid(MyString, i, 1)) = 0 Then
CountPlus = CountPlus + 1
End If

Next i


End Function


"Mark" wrote:

I am interested in doing a count of entries within a cell. It would be
similar to a word count, but instead of counting words, I need to count the
plus signs (+) or something like that. I have a simple formula in the cell
like:

=100+1235+3456+0987+etc

and am only interested in determining how many entries are in there since
each number entry represents a program and I would like to know how many
programs are accounted for.

I've tried this variation on the word wount, but no success:

=IF(LEN(TRIM(B4))=0,0,LEN(TRIM(B4))-LEN(SUBSTITUTE(B4,CHAR(43)," "))+1)

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default counting entries within a cell's formula

I grind my teeth everytime I see people write complicated functions on the
worksheet when they can write code that can easily be debug in VBA.

to test the code there is a full debugger in VBA. Highlight the 1st line of
the function and press F9. The line goes yellow indicating this is a break
point. Now go back to the worksheet and change the cell calling the
function. Excel will go to VBA and stop on the code. You can see the values
of variables by moving the mouse over the variables. You can also add the
variables to a watch window by right clicking on the variable. Very Powerful.

"Mark" wrote:

cool, it works great, thanks for the help! And now I understand how to ad
some new custom functionality too!

"Joel" wrote:

I don't know if my previous reply got posted.
It is easy to use this function.

1) go to the tab on the bottom of the worksheet (normally sheet1) and right
click. Select view code
2) Go to VBA Menu and select insert Module. a new module 1 will be shown.

3) Paste code from Function to End Function.
4) Remove the that this website inserts.
5) You are done.


Use this function like any other function

=CountPlus(A3)

A3 will have a formula like =A1+A2


"Mark" wrote:

I've done my share of heavy Excel programming, but am a bit lost as to how
you would write this into a functional formula. Can you please elaborate on
how to create this custom function? Thanks

"Joel" wrote:

thsi custom function will count plus signs. The number of words is one more
than the plus signs

Function CountPlus(Mycell As Range)

MyString = Mycell.Formula
CountPlus = 0
For i = 1 To Len(MyString)

If StrComp("+", Mid(MyString, i, 1)) = 0 Then
CountPlus = CountPlus + 1
End If

Next i


End Function


"Mark" wrote:

I am interested in doing a count of entries within a cell. It would be
similar to a word count, but instead of counting words, I need to count the
plus signs (+) or something like that. I have a simple formula in the cell
like:

=100+1235+3456+0987+etc

and am only interested in determining how many entries are in there since
each number entry represents a program and I would like to know how many
programs are accounted for.

I've tried this variation on the word wount, but no success:

=IF(LEN(TRIM(B4))=0,0,LEN(TRIM(B4))-LEN(SUBSTITUTE(B4,CHAR(43)," "))+1)

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default counting entries within a cell's formula

Joel

May I modify the CountPlus Function a bit to provide a little more flexibility?

Function CountPlus(Mycell As Range, letter As String)
MyString = Mycell.Formula
CountPlus = 0
For i = 1 To Len(MyString)
If StrComp(UCase(letter), Mid(MyString, i, 1)) = 0 Then
CountPlus = CountPlus + 1
End If
Next i
End Function

Usage is: =CountPlus(cellref,"char")

Where "char" can be any character rather than just the "+" sign.


Gord Dibben MS Excel MVP

On Wed, 14 Mar 2007 10:56:00 -0700, Joel wrote:

I don't know if my previous reply got posted.
It is easy to use this function.

1) go to the tab on the bottom of the worksheet (normally sheet1) and right
click. Select view code
2) Go to VBA Menu and select insert Module. a new module 1 will be shown.

3) Paste code from Function to End Function.
4) Remove the that this website inserts.
5) You are done.


Use this function like any other function

=CountPlus(A3)

A3 will have a formula like =A1+A2


"Mark" wrote:

I've done my share of heavy Excel programming, but am a bit lost as to how
you would write this into a functional formula. Can you please elaborate on
how to create this custom function? Thanks

"Joel" wrote:

thsi custom function will count plus signs. The number of words is one more
than the plus signs

Function CountPlus(Mycell As Range)

MyString = Mycell.Formula
CountPlus = 0
For i = 1 To Len(MyString)

If StrComp("+", Mid(MyString, i, 1)) = 0 Then
CountPlus = CountPlus + 1
End If

Next i


End Function


"Mark" wrote:

I am interested in doing a count of entries within a cell. It would be
similar to a word count, but instead of counting words, I need to count the
plus signs (+) or something like that. I have a simple formula in the cell
like:

=100+1235+3456+0987+etc

and am only interested in determining how many entries are in there since
each number entry represents a program and I would like to know how many
programs are accounted for.

I've tried this variation on the word wount, but no success:

=IF(LEN(TRIM(B4))=0,0,LEN(TRIM(B4))-LEN(SUBSTITUTE(B4,CHAR(43)," "))+1)


  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default counting entries within a cell's formula

Then you should also change the name of the function! It would silly to have
a function called CountPlus() counting minus signs.

"Gord Dibben" wrote:

Joel

May I modify the CountPlus Function a bit to provide a little more flexibility?

Function CountPlus(Mycell As Range, letter As String)
MyString = Mycell.Formula
CountPlus = 0
For i = 1 To Len(MyString)
If StrComp(UCase(letter), Mid(MyString, i, 1)) = 0 Then
CountPlus = CountPlus + 1
End If
Next i
End Function

Usage is: =CountPlus(cellref,"char")

Where "char" can be any character rather than just the "+" sign.


Gord Dibben MS Excel MVP

On Wed, 14 Mar 2007 10:56:00 -0700, Joel wrote:

I don't know if my previous reply got posted.
It is easy to use this function.

1) go to the tab on the bottom of the worksheet (normally sheet1) and right
click. Select view code
2) Go to VBA Menu and select insert Module. a new module 1 will be shown.

3) Paste code from Function to End Function.
4) Remove the that this website inserts.
5) You are done.


Use this function like any other function

=CountPlus(A3)

A3 will have a formula like =A1+A2


"Mark" wrote:

I've done my share of heavy Excel programming, but am a bit lost as to how
you would write this into a functional formula. Can you please elaborate on
how to create this custom function? Thanks

"Joel" wrote:

thsi custom function will count plus signs. The number of words is one more
than the plus signs

Function CountPlus(Mycell As Range)

MyString = Mycell.Formula
CountPlus = 0
For i = 1 To Len(MyString)

If StrComp("+", Mid(MyString, i, 1)) = 0 Then
CountPlus = CountPlus + 1
End If

Next i


End Function


"Mark" wrote:

I am interested in doing a count of entries within a cell. It would be
similar to a word count, but instead of counting words, I need to count the
plus signs (+) or something like that. I have a simple formula in the cell
like:

=100+1235+3456+0987+etc

and am only interested in determining how many entries are in there since
each number entry represents a program and I would like to know how many
programs are accounted for.

I've tried this variation on the word wount, but no success:

=IF(LEN(TRIM(B4))=0,0,LEN(TRIM(B4))-LEN(SUBSTITUTE(B4,CHAR(43)," "))+1)



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
Counting entries Dos Equis Excel Worksheet Functions 4 November 20th 06 03:24 AM
Counting Unique Entries SouthCarolina Excel Discussion (Misc queries) 7 April 14th 06 01:18 PM
Counting Duplicate Entries No_name Excel Worksheet Functions 1 July 18th 05 04:01 PM
Counting Entries Jimbo Excel Worksheet Functions 6 April 29th 05 08:27 PM
Counting Entries in a Cell Sh0t2bts Excel Worksheet Functions 0 February 15th 05 10:08 AM


All times are GMT +1. The time now is 12:06 AM.

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

About Us

"It's about Microsoft Excel"