Categorizing Bank statements

jklarsen

New Member
Joined
Aug 11, 2009
Messages
22
Hi All,

I have been trying to find a previous reply to my challenge with no luck, so I am taking the chance a asking you this.

I want to categorise my bank statements and a spending overview, based upon predefined shop names and categories.

- So basically I paste my bank statement into the sheet.
- I have a prefilled sheet with shop names which I update manually
- I want to index bank statement with the predefined shop name
- Finally I want to generate an yearly overview of my spending throughout the year for each category.

Like this:
Screenshot 2021-01-04 at 18.17.00.png


I can't figure out how to:
3. Search for the shop names in the bank statement text and return the shop name, main category and sub category
4. Search for the amount of sub categories in each month, returning the SUM

I also have the file here in my dropbox - Bank Statements.xlsx


Can anybody help guide, how to do this?

Kind regards,

Jan H.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
1. I Use 2 helper columns. then Add formula.
2. I changed Home Depot to Depot because of two part name.
Bank Statements.xlsx
ABCDEFGHIJ
21. Bank Statements
3DateamountStatement Text<--- Pasted from my online bank
41/1/2021$42.00Mastercard-nota $ 42,00 McdonaldsMcdonalds42,00McDonaldsPersonal spendingFast food & Take away
51/4/2021$38.00Visa purchase $ 38,00 APCOA PARKINGPARKINGAPCOAAPCOATransportationParking
61/6/2021$42.00Mastercard-nota $ 42,00 McdonaldsMcdonalds42,00McDonaldsPersonal spendingFast food & Take away
72/8/2021$27.00Mastercard-nota $ 27,00 MCDonaldsMCDonalds27,00McDonaldsPersonal spendingFast food & Take away
83/1/2021$22.00Paypal: Netflix subscriptionsubscriptionNetflixNetflixOther living costsTV & Streaming
93/10/2021$22.00Paypal: Netflix subscriptionsubscriptionNetflixNetflixOther living costsTV & Streaming
104/14/2021$12.00VISA PharmacyPharmacy#VALUE!PharmacyPersonal spendingDoctors & Treatment
115/20/2021$6.00VISA Home DepotDepotHomeDepotHousingFurniture & housing equipment
12
13
142. Shop names
15NameMain categorySub category<--- Manually added
16McDonaldsPersonal spendingFast food & Take away
17APCOATransportationParking
18NetflixOther living costsTV & Streaming
19PharmacyPersonal spendingDoctors & Treatment
20DepotHousingFurniture & housing equipment
Sheet1
Cell Formulas
RangeFormula
E4:E11E4=RIGHT(D4,LEN(D4)-FIND(CHAR(160),SUBSTITUTE(D4," ",CHAR(160),LEN(D4)-LEN(SUBSTITUTE(D4," ","")))))
F4:F11F4=MID(D4,FIND(CHAR(160),SUBSTITUTE(D4," ",CHAR(160),LEN(D4)-1-LEN(SUBSTITUTE(D4," ","")))),FIND(CHAR(160),SUBSTITUTE(D4," ",CHAR(160),LEN(D4)-LEN(SUBSTITUTE(D4," ",""))))-FIND(CHAR(160),SUBSTITUTE(D4," ",CHAR(160),LEN(D4)-1-LEN(SUBSTITUTE(D4," ","")))))
G4:G11G4=IFNA(VLOOKUP(TRIM(E4),$B$15:$D$20,1,FALSE),VLOOKUP(TRIM(F4),$B$15:$D$20,1,FALSE))
H4:H11H4=IFNA(VLOOKUP(TRIM(E4),$B$15:$D$20,2,FALSE),VLOOKUP(TRIM(F4),$B$15:$D$20,2,FALSE))
I4:I11I4=IFNA(VLOOKUP(TRIM(E4),$B$15:$D$20,3,FALSE),VLOOKUP(TRIM(F4),$B$15:$D$20,3,FALSE))
 
Upvote 0
Hi Thank you for your quick reply.
The formula works great, when the company name is the last part of the text, but most cases bank statements will look like this:

Visa purchase DKK 228,00 TORVEHALLERNES FRUGT Den 22.07
Visa purchase DKK 221,50 Hav Torvehallerne AS Den 22.07
Visa purchase DKK 140,00 THE COFFEE COLLECTIV Den 22.07
Visa purchase DKK 100,00 STIGS OLIVEN APS K Den 22.07
Visa purchase DKK 100,00 LAURAS BAKERY TORVEH Den 22.07

And then the formulas does not work
So the text will quite often be mixed into the text, also some times the shop name will need to be in two words, in case there are similar stores of different categories.

Thanks


Best...Jan
 
Upvote 0
Please upload file with more example at Free hosting site e.g. www.Dropbox.com , GoogleDrive or Onedrive and insert link here to work on it
 
Upvote 0
Use this two User Defined Function. you should at VBA window insert Module and Paste code then save file as .xlsm (Macro-Enabled Workbook)
Then you can use it same as excel functions.
1. CrCell is your criteria Cell at example file you can select D4 to D17 and you should fix column Letter. $D4
2. ShopNameRange is your Shops name range at example file is B20:D31 and you should fix it $B$20:$D$31
3. Col is your column that you want return result form Shops name range
Example:
Excel Formula:
ExtractShopName($D4,$B$20:$D$31,1)

VBA Code:
Function ExtractShopName(CrCell As Range, ShopRange As Range, Col As Long) As String
  Dim Cell As Range, Tr As String, a As Long, P1 As String, P2 As String, P3 As String, P4 As String
  Dim P5 As String, P6 As String, b As Integer
    Tr = Application.WorksheetFunction.Trim(Application.WorksheetFunction.Clean(Replace(CrCell, Chr(160), " ")))
    a = Len(Tr) - Len(Application.WorksheetFunction.Substitute(Tr, " ", ""))
For b = 1 To a
   P1 = FindN(" ", Tr, a - b + 1)
   P2 = FindN(" ", Tr, a - b + 2) - P1 - 1
       If FindN(" ", Tr, a - b + 2) = 0 Then
             P2 = Len(Tr) - P1
      End If
   P3 = Mid(Tr, P1 + 1, P2)
On Error Resume Next
   P4 = Application.WorksheetFunction.VLookup(P3, ShopRange, Col, False)
      If Err <> 0 Then
            GoTo Resum1
      End If
    GoTo Resum3
    Resum1:
 Next b
For b = 2 To a
    P1 = FindN(" ", Tr, a - b + 1)
    P2 = FindN(" ", Tr, a - b + 3) - P1 - 1
          If FindN(" ", Tr, a - b + 3) = 0 Then
              P2 = Len(Tr) - P1
         End If
   P3 = Mid(Tr, P1 + 1, P2)
On Error Resume Next
  P4 = Application.WorksheetFunction.VLookup(P3, ShopRange, Col, False)
        If Err <> 0 Then
          GoTo Resum2
       End If
Resum2:
Next b
    If P4 = "" Then
       If Col = 1 Then
           ExtractShopName = "Others"
       Else
          ExtractShopName = ""
     End If
       Exit Function
    Else
       Resum3:
       ExtractShopName = P4
   End If
End Function

Function FindN(sFindWhat As String, sInputString As String, N As Integer) As Integer
    Dim J As Integer
    Application.Volatile
    FindN = 0
    For J = 1 To N
        FindN = InStr(FindN + 1, sInputString, sFindWhat)
        If FindN = 0 Then Exit For
    Next
End Function
 
Upvote 0
Brilliant - that works great.

There is some cases where I need to add a " " after the name for it to work, and then I can find the shop name, but it still does not find the Main and sub category afterwards.

1609924904619.png


I have copied/pasted the text directly from the bank statement into the shop names cells, so they are identical, and also formatted them all as TEXT.

Am I doing something wrong?


Best...Jan
 
Upvote 0
I seem to have found a solution for finding the shopname from on of the other threads, by mixing and matching

=INDEX(Butiksnavne!$B$3:$B$5000;AGGREGATE(15;6;(ROW(Butiksnavne!$B$3:$B$5000)-ROW(Butiksnavne!$B$3)+1)/(ISNUMBER(SEARCH(Butiksnavne!$B$3:$B$5000;C3)));1))

So now I need to figure out how to search within months, the sum from each category and adding the sum to the corresponding cells, like this

1609930400751.png


Is there an easy way to do this?


Best...Jan
 
Upvote 0
what is formula you use for shopname, main and subcategory Exactly?
I think you don't enter formula correctly.
 
Upvote 0
I use the formula you created and they work like a charm

=IFNA(VLOOKUP(TRIM(E3);Butiksnavne!$B$3:$D$5000;2;FALSE);VLOOKUP(TRIM(E3);Butiksnavne!$B$3:$D$500;2;FALSE))

And when using it together with the new formula, everything works fine
=INDEX(Butiksnavne!$B$3:$B$5000;AGGREGATE(15;6;(ROW(Butiksnavne!$B$3:$B$5000)-ROW(Butiksnavne!$B$3)+1)/(ISNUMBER(SEARCH(Butiksnavne!$B$3:$B$5000;C3)));1))



So now I need to figure out how to search within months, the sum from each category and adding the sum to the corresponding cells, like this

1609930400751.png



Is there an easy way to do this?


Best...Jan
 
Upvote 0

Forum statistics

Threads
1,215,002
Messages
6,122,652
Members
449,092
Latest member
peppernaut

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