macro is rounding up and down

smiler44

Registered User.
Local time
Today, 19:49
Joined
Jul 15, 2008
Messages
641
I have a macro comparing the value of two cells next to each other but 39.99 is being rounded up to 40 and 33.17 rounded down to 33.
I have no idea why or how to cure it, please can you advise?
Below is my code and it is Excel 2007

thank you

Dim rt As String ' number of times
Dim ev As Integer
Dim rv As Integer


Sub loss()

Range("B7").Activate
Do Until ActiveCell.Value = ""
If ActiveCell.Value = 1 Then
ActiveCell.Offset(0, 3).Activate 'across 3
ev = ActiveCell.Value
ActiveCell.Offset(0, 1).Activate
rv = ActiveCell.Value
ActiveCell.Offset(1, -4).Activate
Else
ActiveCell.Offset(1, 0).Select 'down 1 across 0
GoTo nxt
End If

If ev > rv Then
rt = rt + 1
ev = "0"
rv = "0"
MsgBox ("ev greater then rv")
End If

nxt:
Loop

End Sub
 
The Integer data type can't hold a decimal. I'd use Currency.
 
The Integer data type can't hold a decimal. I'd use Currency.
thank you pbaldy, currency has worked. I never knew integer could not deal with decimals.

smiler44
 

Users who are viewing this thread

Back
Top Bottom