Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default I'm adding 1.5 & 1 and VBA is telling me its 2 ?!?!

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default I'm adding 1.5 & 1 and VBA is telling me its 2 ?!?!

? 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)

--
Regards,
Tom Ogilvy



"dan" wrote:

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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
telling range when to stop. cereldine[_16_] Excel Programming 2 April 13th 06 12:11 PM
Telling a website what to do!! gunny1979[_3_] Excel Programming 1 April 1st 06 04:47 AM
Telling a procedure to end Phil1982 Excel Programming 1 March 16th 06 11:58 PM
Telling MSGraph which cell I need KD[_3_] Excel Programming 0 June 18th 04 12:12 PM
telling Excel to go down relatively CC[_4_] Excel Programming 3 April 22nd 04 10:59 PM


All times are GMT +1. The time now is 10:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"