Strange Formula Problem

jaysh

New Member
Joined
Jul 30, 2006
Messages
16
It's me again. Just want to thank you guys again for being very helpful.

Have a weird problem.

If i'm in excel and do =sum(at:at) it comes out to a dollar amount of 42.99 (expected)

However, when i'm in VBA and doing:

Set freight = ws1.Range("AT:AT")

ws3.Range("B2") = Application.Sum(freight)

It comes pretty close to the number but instead it is something like 42.989932

The weird part is that there are no extra decimel places anywhere in column AT to give it these extra places. Any ideas?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
It's a floating point issue likely. All computer programs suffer from it. It stems from converting numbers from base 10 to binary. Sometimes it doesn't go as cleanly as humans interpret.
 
Upvote 0
So from what it sounds like, there is no fix for that? I mean the numbers are so close that I can't see it being a problem. However, I want to make sure that if I go into alot higher numbers, it wont be throwing it off by dollars.

Any help?

Thanks!
 
Upvote 0
Checked over your file. VBA is returning a different value (albeit the same when formatted) compared to doing AutoSum.

You could use some form of rounding method after doing the Application.Sum or instead of this code:

Code:
Set freight = ws1.Range("AT:AT")
ws3.Range("B2") = Application.Sum(freight)

you could run
Code:
Set freight = ws1.Range("AT:AT")
ws3.Range("B2").Formula = "=SUM(AT:AT)"
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top