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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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,224,552
Messages
6,179,487
Members
452,917
Latest member
MrsMSalt

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