Multiple statement lines per transaction

Nygie

Board Regular
Joined
Apr 15, 2015
Messages
50
Good morning all.

Recently I have been tasked with the rarity of a physical bank statement. the easy answer to my question is to get the statement in CSV but this is not always possible.

The statement in question when scanned from PDF generates up to 6 lines for the transaction description example below. I was wondering if there is a way to make it one line per transaction combining the multiple description cells and deleting the blank lines left behind.
I almost have it in my head that the date cell needs to be read and count empty cells below, if empty cells are detected cut the data for the last 4 cells and add to the line above until the line is a single line, delete the lines just made empty and repeat.
Sounds simple when I say that but my coding skills are lacklustre at best. After doing some Googling Concatenate function appeared frequently.
Any idea/pointers in the right direction would be appreciated.
Many thanks
DateDetailsDescriptionWithdrawnPaid InBalance
4/1/2021​
Online TransactionStation
Pub
VIA MOBILE - PYMT
1,000.00​
1,525.10​
4/1/2021​
Charges11DEC A/C xxxxxx
8.00​
1,517.10​
05/01/2021​
OnLine TransactionJohn Smith
WAGE
VIA ONLINE - PYMTB
715.00​
2,232.10​
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
with Power Query:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    lst = List.Zip({List.Skip(Source[Date]), {1.. List.Count(Source[Date])-1}}),
    lst1 = List.Accumulate(lst, {1}, (s,c)=> s & (if c{0} = null then {List.Last(s)} else {List.Last(s) +1 }  )),
    tcn = Table.ColumnNames(Source),
    tbl = Table.FromColumns({lst1} & Table.ToColumns(Source), {"ID"} & tcn),
    Group = Table.Group(tbl, {"ID"}, {{"All", each 
        let 
            Fill = Table.FillUp(_,{"Withdrawn", "Paid In", "Balance"}),
            tbl1 = Table.FirstN(Fill,1),
            tbl2 = Table.TransformColumns(tbl1, {"Description", (x)=> Text.Combine(Fill[Description], "; ")})
        in 
            tbl2}}),
    RemoveColumn = Table.RemoveColumns(Group,{"ID"}),
    Expand = Table.ExpandTableColumn(RemoveColumn, "All", tcn)
in
    Expand

Book1
ABCDEFGHIJKLMN
1DateDetailsDescriptionWithdrawnPaid InBalanceDateDetailsDescriptionWithdrawnPaid InBalance
24/1/2021Online TransactionStation4/1/2021Online TransactionStation; Pub; VIA MOBILE - PYMT1,000.001,525.10
3Pub4/1/2021Charges11DEC A/C xxxxxx8.001,517.10
4VIA MOBILE - PYMT1,000.001,525.1005/01/2021OnLine TransactionJohn Smith; WAGE; VIA ONLINE - PYMTB715.002232.1
54/1/2021Charges11DEC A/C xxxxxx8.001,517.10
605/01/2021OnLine TransactionJohn Smith
7WAGE
8VIA ONLINE - PYMTB715.002232.1
9
Sheet1
 
Upvote 1
Solution
Thanks JGordon11. I have seen reference to power query earlier in my searches. On looking I am in luck having Excel 2010 :)
 
Upvote 0
It worked a treat thank you, I tried following the code and its all greek to me. Never seen power query code before :)
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,645
Members
449,461
Latest member
kokoanutt

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