Example Input from the bank as follows:
04APR WITHDRAWAL BY EFTPOS
0800991 BP ETON VALE
0341 CAMBOOYA
04/04 40.83 866.46
07APR WITHDRAWAL BY EFTPOS
0000795 TONIS SUPER
MEATS 0001 TOOWOOMBA
05/04 33.65 832.81
07APR WITHDRAWAL BY EFTPOS
0021262 DELI DELICIOUS
TOOWOOMBA
05/04 56.00 776.81
07APR WITHDRAWAL BY EFTPOS
0043917 WOOLWORTHS
2516 KEARNEYS S
05/04 224.33 552.48
Output is in columns:
Date Text Debit Credit
The Bank only alows transactions for the last 6 months to be downloaded,
however you can access eStatements for the prior 3 years.
This macro allows each transaction spread over multiple rows to be
output in a single row. The macro asks for the Year for the first
transaction and provided there are transactions for December and Janurary
the macro detects the year change.
Sheet 1 contains the text from the bank. Sheet 2 has the extracted data in it
Public Sub Convert()
Dim xl As Excel.Application
Dim wb As Excel.Workbook
Dim ws1 As Excel.Worksheet
Dim ws2 As Excel.Worksheet
Set xl = Application
Set wb = xl.ThisWorkbook
Set ws1 = wb.Sheets(1)
Set ws2 = wb.Sheets(2)
ws2.Cells.ClearContents
Dim t As String
Dim w As String
Dim s As Integer
Dim w2 As Integer
Dim Debit As Double
Dim Credit As Double
Dim dte As Date
Dim LastLine As Boolean
Dim sYr As String
Dim sMonth As String
Dim PriorMonth As String
Dim Yr As Long
Dim iOK As Boolean
s = 1
w2 = 0
w = ""
iOK = False
While iOK = False
sYr = InputBox("Enter Year", " Start Year for First Statement Year", "2014")
If IsNumeric(sYr) Then
Yr = Val(sYr)
If Yr > 2000 And Yr < 2050 Then
iOK = True
End If
End If
If iOK = False Then
MsgBox "Year is Invalid", vbCritical, "Error in Year"
End If
Wend
'Yr = 2013
pyr1 = "-2012"
yr2 = "-2011"
t = ws1.Cells(s, 1).Value + Space(60)
sMonth = Mid(t, 3, 3)
While ws1.Cells(s, 1).Value <> ""
If Mid(t, 3, 3) <> " " Then
PriorMonth = sMonth
sMonth = Mid(t, 3, 3)
If PriorMonth = "DEC" And sMonth = "JAN" Then
Yr = Yr + 1
End If
dte = CDate(Mid(t, 1, 2) & "-" & Mid(t, 3, 3) & "-" & Val(Yr))
LastLine = False
While LastLine = False
If Mid(t, 40, 1) = "." Or Mid(t, 49, 1) = "." Then
LastLine = True
End If
w = w + " " + Trim(Mid(t, 7, 24))
If LastLine = True Then
Credit = 0
Debit = 0
If Mid(t, 40, 1) = "." Then
Debit = CDbl(Trim(Mid(t, 31, 14)))
End If
If Mid(t, 49, 1) = "." Then
Credit = CDbl(Trim(Mid(t, 44, 8)))
End If
w2 = w2 + 1
ws2.Cells(w2, 1).Value = dte
ws2.Cells(w2, 2).Value = w
ws2.Cells(w2, 3).Value = Debit
ws2.Cells(w2, 4).Value = Credit
w = ""
End If
s = s + 1
t = ws1.Cells(s, 1).Value + Space(60)
Wend
End If
t = ws1.Cells(s, 1).Value + Space(60)
Wend
End Sub