Formatting VBA Variables as Currency

dgav1480

New Member
Joined
Jan 6, 2006
Messages
42
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?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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
 
Upvote 0
I figured it out

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

Forum statistics

Threads
1,214,605
Messages
6,120,473
Members
448,967
Latest member
visheshkotha

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