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

If a plus sign is always going to be the separator, this UDF will work. To
implement, simply type =CountValues(A1) in your spreadsheet.

Function CountValues(cell)
form = cell.Formula
Length = Len(form)
Count = 0
For i = 1 To Length
If Mid(form, i, 1) = "+" Then
Count = Count + 1
End If
Next i
CountValues = Count + 1
End Function

--
Regards,
Dave


"CRH" wrote:

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