VBA Code: Bank Account Balance Macro

Patty Can

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

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
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."
End Sub

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Latest member

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...