View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Sum that ignores text

I got the impression that the OP was getting formula like strings in the
textboxes in a userform. If my guess is correct, then I don't think this is
better.

And if the values in that range are really strings that look like:
1234+345+234
Then I don't think =sum() or =sumproduct() will help.

Joel wrote:

Sumproduct is smarter than sum. Try this function

=SUMPRODUCT((--VALUE(A1:A3)))

"Dave Peterson" wrote:

=sum() adds numbers.

Strings like: 1234+34-3465-2345+(1234/2143)
aren't numbers

But maybe you could use application.evaluate() to evaluate a string that looks
like a formula.



Smurfette18 wrote:

Hi,

I am trying to do a simple sum using inputs taken from userform
comboboxes. The problem is that the inputs can contain the text
character "-", and this is causing an error. I have tried converting
the inputs to values using val, cval, cdec, etc, but I think that the
problem is that the application.sum function in VBA, like the simple
operation "+", can't handle text. Any ideas about how to deal with
this?

Thanks!
-Tim


--

Dave Peterson


--

Dave Peterson