LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem With Decimal Point


Hi,

I am a newbie in VBA programing. I have written a subroutine t
calculate gas pressure in soft drink package.

- If the pressure entered in column D is between 11.6 and 12 then O
is displayed in column E

- If the pressure entered in column D is greater than 12 or less tha
11.6 then the difference between 11.8 and the pressure entered will b
displayed in column E together with the alphabet H or L as the case ma
be.

My problem is that if the pressure entered in column D is 12.1 th
display in column E is expected to be 0.3 H but instead I go
0.299999999999999H. If the pressure entered in column D is 11.5 th
display in column E became -0.300000000000001L instead of -0.3L .

Can someone tell me what is wrong with my subroutine ?

Thanks

Subroutine is as follows:

Do While Not IsEmpty(Cells(n, "B"))
Dim n As Integer
n = 6


If Cells(n, "B").Value = "APPLE" And (Cells(n, "C").Value = "PE
500" _
Or Cells(n, "C").Value = "PET 1500") And Cells(n, "D").Value <= 1
_
And Cells(n, "D").Value = 11.6 Then
Cells(n, "E").Value = "OK"

ElseIf Cells(n, "B").Value = "APPLE" And (Cells(n, "C").Value
"PET 500" _
Or Cells(n, "C").Value = "PET 1500") And Cells(n, "D").Value 1
Then
Cells(n, "E").Value = Cells(n, "D") - 11.8 & "H"

ElseIf Cells(n, "B").Value = "APPLE" And (Cells(n, "C").Value
"PET 500" _
Or Cells(n, "C").Value = "PET 1500") And Cells(n, "D").Value < 11.
_
And Cells(n, "D").Value 0 Then
Cells(n, "E").Value = Cells(n, "D") - 11.8 & "L"

End If

n=n+1
Loop
End su

--
sifuconma
-----------------------------------------------------------------------
sifuconman's Profile: http://www.excelforum.com/member.php...fo&userid=3701
View this thread: http://www.excelforum.com/showthread.php?threadid=56780

 
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
Decimal Point... Zoe Excel Discussion (Misc queries) 4 February 26th 10 03:38 PM
Decimal point Jock Excel Discussion (Misc queries) 4 May 4th 07 02:02 PM
How can I get a zero to appear after decimal point Mark0145 New Users to Excel 4 October 21st 06 12:47 AM
Converting 2-place decimal value to floating point decimal number with leading zero Kermit Piper Excel Discussion (Misc queries) 3 March 18th 06 06:20 PM
FIXED 2 DECIMAL PLACES, MUST ENTER ALL ZEROES AFTER DECIMAL POINT. SUKYKITTY Excel Discussion (Misc queries) 3 July 6th 05 01:50 PM


All times are GMT +1. The time now is 06:58 AM.

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"