VBA Code: Bank Account Balance Macro

Patty Can

New Member
Joined
Jul 20, 2010
Messages
4
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
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top