Hi,
I have a vba macro in excel that loads a text file, parses through the lines and adds up two different values from the records.
When I look at the values they are exactly the same, but with I use them in a 'if' statement or set another variable to the subtracted result I get some wierd 9.1023xxx number.
Can someone help me figure out what's wrong in my macro.
Ex: DepAmt= 5746.49
DebAmt= 5746.49
v=DepAmt-DebAmt
: v : 9.09494701772928E-13 : Variant/Double
======
Here's the part of my code that parses and totals:
Dim Msg, T As String
Dim PayDt
Dim DepAmt As Double, DebAmt As Double, Tmp As Double
For R = 1 To RW
T = Range("A" & R).Value 'Record Id
'
' Batch Header 'Get pay Date
'
If T = "520" Then
PayDt = Mid(Range("B" & R).Value, 67, 6) 'Dt
End If
'
' Debit Record (TRansfer)
'
If T = "627" Then 'Debit record
Tmp = Mid(Range("B" & R).Value, 27, 10)
DebAmt = DebAmt + (Tmp / 100) 'Debit $
End If
'
' Employee Deposit amounts
'
If T = "632" Or T = "622" Then 'Deposit record
Tmp = Mid(Range("B" & R).Value, 27, 10)
DepAmt = DepAmt + (Tmp / 100) 'Deposit $
End If
Next R
'
' Verify Deposit and Debit amounts Match
'
v = DepAmt - DebAmt 'test
If (DepAmt - DebAmt) > 0 Then 'GOT A PROBLEM
Msg = "Employee Deposits of [$" & DepAmt & "] does not match Employer" & _
" debit [$" & DebAmt & "]. Call Lee/Gail."
x = MsgBox(Msg, 0)
GoTo Exitout
End If
I have a vba macro in excel that loads a text file, parses through the lines and adds up two different values from the records.
When I look at the values they are exactly the same, but with I use them in a 'if' statement or set another variable to the subtracted result I get some wierd 9.1023xxx number.
Can someone help me figure out what's wrong in my macro.
Ex: DepAmt= 5746.49
DebAmt= 5746.49
v=DepAmt-DebAmt
: v : 9.09494701772928E-13 : Variant/Double
======
Here's the part of my code that parses and totals:
Dim Msg, T As String
Dim PayDt
Dim DepAmt As Double, DebAmt As Double, Tmp As Double
For R = 1 To RW
T = Range("A" & R).Value 'Record Id
'
' Batch Header 'Get pay Date
'
If T = "520" Then
PayDt = Mid(Range("B" & R).Value, 67, 6) 'Dt
End If
'
' Debit Record (TRansfer)
'
If T = "627" Then 'Debit record
Tmp = Mid(Range("B" & R).Value, 27, 10)
DebAmt = DebAmt + (Tmp / 100) 'Debit $
End If
'
' Employee Deposit amounts
'
If T = "632" Or T = "622" Then 'Deposit record
Tmp = Mid(Range("B" & R).Value, 27, 10)
DepAmt = DepAmt + (Tmp / 100) 'Deposit $
End If
Next R
'
' Verify Deposit and Debit amounts Match
'
v = DepAmt - DebAmt 'test
If (DepAmt - DebAmt) > 0 Then 'GOT A PROBLEM
Msg = "Employee Deposits of [$" & DepAmt & "] does not match Employer" & _
" debit [$" & DebAmt & "]. Call Lee/Gail."
x = MsgBox(Msg, 0)
GoTo Exitout
End If