View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Niek Otten
 
Posts: n/a
Default count number of values between plus signs in addition calc

Hi Cathy,

Use this User Defined Function.
If you're new to VBA, look here first:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

Function CountAdd(a As Range) As Double
Dim i As Long
Dim b As String
b = a.Formula
For i = 1 To Len(b)
If Asc(Mid$(b, i, 1)) = 43 Then CountAdd = CountAdd + 1
Next i
CountAdd = CountAdd + 1
End Function

--
Kind regards,

Niek Otten


"CRH" wrote in message
...
I'd like to count the number of values that a user enters in an excel
simple
addition calculation.

For example, if the cell has "=17+256", I'd like to get the count of "2".
If the cell has "=101+2+0+65", I'd like to get the count of "4". Is there
a
way to parse this 'function' string?

Everything I've tried so far starts *after* the cell value has been
calculated (e.g. it's working with a single value of 273 and a single
value
of 168 for the two examples above, respectively).

Thanks,
- Cathy