Ctrl
11-04-2010, 10:59 AM
Hi
This code says the two values are not equal though they seem to be.
d1stValue should be equal to d2ndValue at the end of the procedure unless i am missing something!!
I put the if condition just to prove the result which is always "False".
Any help will be appreciated.
Excel 2003
XP SP3
Sub Macro1()
Dim iRow As Integer
Dim d1stValue As Double
Dim d2ndValue As Double
intRow = 1
d1stValue = 17.5
d2ndValue = 19.25
Do
With Cells(intRow, 1)
.NumberFormat = "0.00"
.Value = d1stValue
End With
If d1stValue >= d2ndValue Then Exit Do
Select Case d1stValue
Case Is >= 50
d1stValue = d1stValue + 0.25
Case Is >= 25
d1stValue = d1stValue + 0.1
Case Is < 25
d1stValue = d1stValue + 0.05
End Select
intRow = intRow + 1
Loop
Range("B1").Value = d1stValue
Range("C1").Value = d2ndValue
If d1stValue = d2ndValue Then
MsgBox "True"
Else
MsgBox "False"
End If
End Sub
This code says the two values are not equal though they seem to be.
d1stValue should be equal to d2ndValue at the end of the procedure unless i am missing something!!
I put the if condition just to prove the result which is always "False".
Any help will be appreciated.
Excel 2003
XP SP3
Sub Macro1()
Dim iRow As Integer
Dim d1stValue As Double
Dim d2ndValue As Double
intRow = 1
d1stValue = 17.5
d2ndValue = 19.25
Do
With Cells(intRow, 1)
.NumberFormat = "0.00"
.Value = d1stValue
End With
If d1stValue >= d2ndValue Then Exit Do
Select Case d1stValue
Case Is >= 50
d1stValue = d1stValue + 0.25
Case Is >= 25
d1stValue = d1stValue + 0.1
Case Is < 25
d1stValue = d1stValue + 0.05
End Select
intRow = intRow + 1
Loop
Range("B1").Value = d1stValue
Range("C1").Value = d2ndValue
If d1stValue = d2ndValue Then
MsgBox "True"
Else
MsgBox "False"
End If
End Sub