Results 1 to 3 of 3

Formatting VBA Variables as Currency

This is a discussion on Formatting VBA Variables as Currency within the Excel Questions forums, part of the Question Forums category; I'm trying to get the sum of a set of numbers and when I use Format(variable,"Currency"), it leaves the sum ...

  1. #1
    New Member dgav1480's Avatar
    Join Date
    Jan 2006
    Posts
    42

    Default Formatting VBA Variables as Currency

    I'm trying to get the sum of a set of numbers and when I use Format(variable,"Currency"), it leaves the sum with only a decimal point at the end and no numbers to the right of the decimal point. I have verified that there should be numbers to the right of the decimal point, they're just not showing up.

    How can I get VBA to recognize the numbers to the right of a decimal point?

  2. #2
    MrExcel MVP Damon Ostrander's Avatar
    Join Date
    Feb 2002
    Location
    Denver, Colorado USA
    Posts
    4,163

    Default

    Hi dgav1480,

    This is very strange! The "Currency" format should always give a result in the form:

    $123,892.78

    or

    $123,892.00

    if no pennies. So you are getting a result that looks like

    $123,892. or just $123,892

    Is this correct???

    If so, then I suspect that the problem has nothing to do with Excel or Format, but with the Windows default currency representation. To check this go to Control Panel > Regional and Language Options. If the default currency representation displays without cents, click on the Customize button and change it.

    Damon

  3. #3
    New Member dgav1480's Avatar
    Join Date
    Jan 2006
    Posts
    42

    Default I figured it out

    I Dim'ed my variables as Long instead of Double. That seemed to do the trick.

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com