I'm adding 1.5 & 1 and VBA is telling me its 2 ?!?!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to find a way to have VBA give me the sum of multiple non-integers
to the 2nd decimal place. So far, I'm having no luck. I thought formatting
the variable using "#,###.##" might work, but for the sum of 1.5 & 1 it gives
me 2. (It doesn't give me 2.00, just 2. with a lone decimal place after the
2) What can I do to get VBA to recognize the decimal places?
 
? 1.5 + 1.0
2.5
? 1.475 + 2.322
3.797


If you are using variables, make sure they are declared as Single or Double
or Variant. If you declared them as Long or Integer, then there's your
huckleberry. These only hold whole numbers. (or assigned the result to such
a variable)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top