Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sum that ignores text
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sum that ignores text
The Worksheet function SUM() (which you call as Application.Sum) does
handle text by ignoring it. But you said you're converting the inputs to (numeric) values. Does that not work? Perhaps some examples of what you're doing would help to clarify the problem... In article om, 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sum that ignores text
=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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sum that ignores text
MsgBox Val(TextBox1.Text) + Val(TextBox2.Text)
works for me -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Smurfette18" wrote in message ps.com... 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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sum that ignores text
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Set rng for Column A only (ignores other columns) | Excel Programming | |||
Excel ignores "Text qualifiers" in Unicode files | Excel Discussion (Misc queries) | |||
formula ignores last infor - please help | Excel Worksheet Functions | |||
How do you use text in a formula so it will calc, but ignores txt | Excel Discussion (Misc queries) | |||
Min Value using array ignores Zero | Excel Discussion (Misc queries) |