Share via

Application vs WorksheetFunction

Anonymous
2010-08-16T01:24:19+00:00

I'm not sure where this should go so I've posted to both the formula

and vba groups, as well as the old programming group.

Chip Pearson has written that the only difference, when calling an

Excel worksheetfunction, between using the Application object vs the

WorksheetFunction is error handling.

However, the following gives different results, for what appears to be

the same function.  (The result is the same if SheetCredit is declared

as Double).

=========================

Option Explicit

Sub foo()

  Const CashIn As Currency = 53.4

  Const CashDue As Currency = 54.175

  Dim SheetCredit As Currency

    SheetCredit = CashIn - CashDue

    Debug.Print "SheetCredit not Rounded", , SheetCredit

    Debug.Print "WorksheetFunction.RoundDown:", _

        WorksheetFunction.RoundDown(SheetCredit, 2)

    Debug.Print "Application.RoundDown:", , _

        Application.RoundDown(SheetCredit, 2)

End Sub

===============================

Immediate Window:

SheetCredit not Rounded                   -0.775 WorksheetFunction.RoundDown:        -0.77 Application.RoundDown:                    -0.78


Microsoft 365 and Office | Install, redeem, activate | For home | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2010-08-16T11:35:40+00:00

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-08-16T01:30:28+00:00

    On Mon, 16 Aug 2010 01:24:19 +0000, RonRosenfeld <*** Email address is removed for privacy ***>

    wrote:

    (The result is the same if SheetCredit is declared

    as Double).

    That should read that the result of either Application.rounddown or

    Worksheetfunction.RoundDown is the same ...  In other words, it works

    as expected if SheetCredit is Double.

    Was this answer helpful?

    0 comments No comments