Counting Expression in a Single formula

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to figure out a way to count up the number of expressions in a
formula that was created. So for example

=8+10+44+53

This would give me 4. Seems like you should be able to do it but I am not
sure how. Thanks in advance
 
I gave a simple UDF the other day that works for simple + delimiters

Function CountList(rng As Range, Optional delimiter As String = "+")
Dim arg
If rng.Count > 1 Then
CountList = CVErr(xlErrRef)
Else
arg = Split(rng.Formula, delimiter)
CountList = UBound(arg) - LBound(arg) + 1
End If
End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)
 
if always + then try this
=SUM(LEN(SUBSTITUTE(F10,"+","")))+1
 
Thanks. That was perfect

Bob Phillips said:
I gave a simple UDF the other day that works for simple + delimiters

Function CountList(rng As Range, Optional delimiter As String = "+")
Dim arg
If rng.Count > 1 Then
CountList = CVErr(xlErrRef)
Else
arg = Split(rng.Formula, delimiter)
CountList = UBound(arg) - LBound(arg) + 1
End If
End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top