- Joined
- Jul 20, 2010
- Messages
- 2
- Reaction score
- 0
Hi!
I could use some help with this VBA macro. The macro was written to use the data in an excel formatted check register to determine the amount that the bank statement should show as the ending balance. In other words using the Check Register balance and the outstanding checks and deposits balance as of the end of the period, plus one day, the macro calculates what the ending balance should be with the bank. This is a little backwards of the way a bank rec should be but this is the way this macro was written.
The problem is that the macro has a bug in that it is picking up check amount in the row immediately following the bank statement ending date. This consistently results in an error in the amount outstanding by the amount of the item in the row following the statement ending date, plus one day. I know this 'plus one day' thing is confusing but if there is anyone that thinks they might have some understand of this, I can more fully explain that 'plus one day' twist.
Is there anyone out there that knows VBA code that can you see where the error is in the code?
Thanks, Patty
Private Sub cmdGo_Click()
Dim StatementDate As Date
Dim lngBalance As Currency
Dim intRow As Integer
frmBalance.Hide
StatementDate = txtDate.Value
intRow = 17
lngBalance = Sheet1.Range("H" & intRow).Value
Do Until Sheet1.Range("B" & intRow - 1).Value = StatementDate And Sheet1.Range("B" & intRow).Value <> StatementDate
' Sheet1.Range("F" & intRow).Select
If Sheet1.Range("F" & intRow).Value = "x" And Sheet1.Range("J" & intRow).Value <= StatementDate Then
lngBalance = lngBalance - Sheet1.Range("G" & intRow).Value
End If
'MsgBox lngBalance
intRow = intRow + 1
Loop
Sheet1.Range("H" & intRow - 1).Select
lblLabel.Caption = "Statement balance as of " & StatementDate & ":"
lblClearedSoFar.Caption = "$" & lngBalance
Label2.Caption = "As of this date, $" & Sheet1.Range("I" & intRow).Value & " worth of outstanding checks have not been cashed."
frmBalance.Show
End Sub
I could use some help with this VBA macro. The macro was written to use the data in an excel formatted check register to determine the amount that the bank statement should show as the ending balance. In other words using the Check Register balance and the outstanding checks and deposits balance as of the end of the period, plus one day, the macro calculates what the ending balance should be with the bank. This is a little backwards of the way a bank rec should be but this is the way this macro was written.
The problem is that the macro has a bug in that it is picking up check amount in the row immediately following the bank statement ending date. This consistently results in an error in the amount outstanding by the amount of the item in the row following the statement ending date, plus one day. I know this 'plus one day' thing is confusing but if there is anyone that thinks they might have some understand of this, I can more fully explain that 'plus one day' twist.
Is there anyone out there that knows VBA code that can you see where the error is in the code?
Thanks, Patty
Private Sub cmdGo_Click()
Dim StatementDate As Date
Dim lngBalance As Currency
Dim intRow As Integer
frmBalance.Hide
StatementDate = txtDate.Value
intRow = 17
lngBalance = Sheet1.Range("H" & intRow).Value
Do Until Sheet1.Range("B" & intRow - 1).Value = StatementDate And Sheet1.Range("B" & intRow).Value <> StatementDate
' Sheet1.Range("F" & intRow).Select
If Sheet1.Range("F" & intRow).Value = "x" And Sheet1.Range("J" & intRow).Value <= StatementDate Then
lngBalance = lngBalance - Sheet1.Range("G" & intRow).Value
End If
'MsgBox lngBalance
intRow = intRow + 1
Loop
Sheet1.Range("H" & intRow - 1).Select
lblLabel.Caption = "Statement balance as of " & StatementDate & ":"
lblClearedSoFar.Caption = "$" & lngBalance
Label2.Caption = "As of this date, $" & Sheet1.Range("I" & intRow).Value & " worth of outstanding checks have not been cashed."
frmBalance.Show
End Sub