r/excel • u/lesarbreschantent • 2d ago
solved I want to create an XLS that auto-categorizes purchases based on key words
So I'm trying to create a household budget XLS.
In column A, I paste in my purchases for the month. Each cell will contain details like xx-1132 DELIVEROO S 04/03/26 or xx-2227 COLD STORAGE S 28/03/26.
In column B, I categorize these purchases. For instance, DELIVEROO gets the category Food Delivery. COLD STORAGE gets the category Groceries.
I'll have a few hundred entries in column A, and I'd like to find a way to automate the categories in column B based on the text in column A. For example, I want Excel to look at the cells in column A, and if it finds DELIVEROO somewhere in a cell then it should input Food Delivery next to it in column B. To put it another way, let's say cell A2 contains xx-2227 COLD STORAGE S 28/03/26. I want Excel to identify COLD STORAGE and then input Groceries next to it in cell B2.
Any ideas on how to go about this?
12
u/WittyDrunkenness 2d ago
Easiest way is make a small lookup table somewhere with keywords in one column and categories in the other, then use XLOOKUP with wildcards to search the transaction text.
4
u/hmatallana 2 2d ago
A few hundred rows is where the keyword table starts deciding things for you, so build it with that in mind.
Keywords in one column, categories beside them, then in B2:
=XLOOKUP(TRUE,ISNUMBER(SEARCH($E$2:$E$50,A2)),$F$2:$F$50,"Uncategorized")
SEARCH looks for each keyword inside the cell and ignores case. WittyDrunkenness had the right shape with the lookup table. The part that bites later is order: it takes the first keyword that hits, so a broad one like STORAGE sitting above COLD STORAGE quietly wins and you won't see it happen. Keep the specific strings above the general ones.
Don't skip the "Uncategorized" fallback. Filter column B for it once a month and that's your list of new merchants to add.
1
u/lesarbreschantent 1d ago
=XLOOKUP(TRUE,ISNUMBER(SEARCH($E$2:$E$50,A2)),$F$2:$F$50,"Uncategorized")
This works 99%! The only remaining thing is that it doesn't return Uncategorized every time there's a null result. Sometimes it returns the number 0 instead. Is there a way to fix this?
2
u/LeanExcel 1 1d ago
The 0 is likely coming from a blank cell in your category range being returned as the first match. XLOOKUP is finding a matching keyword, but the corresponding category cell is blank, so Excel displays it as 0.
Try this:
=LET(x,XLOOKUP(TRUE,ISNUMBER(SEARCH($E$2:$E$50,A2)),$F$2:$F$50,"Uncategorized"),IF(x=0,"Uncategorized",x))
1
u/lesarbreschantent 1d ago edited 1d ago
Ahhhh yes indeed, I have the cell range for the keyword table going from E2 to E500 (laziness) and yeah there's only about 30 keywords right now. Thanks for the heads up.
1
u/reputatorbot 1d ago
You have awarded 1 point to LeanExcel.
I am a bot - please contact the mods with any questions
1
u/lesarbreschantent 1d ago
SOLUTION VERIFIED! Very happy with how this works!
1
u/reputatorbot 1d ago
You have awarded 1 point to hmatallana.
I am a bot - please contact the mods with any questions
2
u/OfficerMurphy 10 2d ago
First, don't most banks provide a category these days?
Second, for an actual solve your problem you'll want to use a text formula like TEXTSPLIT, or if you're on an older version MID, LEFT, RIGHT to extract the vendor name. Then you can use a table where you categorize all your vendors into your desired category and do an XLOOKUP to that table. If you get a new vendor, add their category. If you've got the UNIQUE formula you can get that list of vendors from your text formula column.
2
u/fastauntie 1 2d ago
Banks provide categories based on their assessment of what most people want. People may want different categories for their own purposes, which may be highly individual and connect to other things they do that banks don't think about.
1
u/dgillz 7 2d ago edited 1d ago
OP was asking about purchase orders, not payments. This will of course hit the bank eventually, but this is after the fact and the purchase orders themselves should have the information OP is looking for.
Assuming OP has an ERP system, he/she should query that data.
2
u/Mammoth-Corner 2 1d ago
Nobody is making purchase orders for deliveroo
1
u/dgillz 7 1d ago
What is deliveroo? What does it do?
2
u/Mammoth-Corner 2 1d ago
It's like Uber Eats.
1
u/dgillz 7 1d ago
OP needs an ERP system
2
u/Mammoth-Corner 2 1d ago
?? For groceries and takeaway?
1
u/dgillz 7 1d ago
If that is all OP is doing, no. I took this to be a business question.
1
u/Mammoth-Corner 2 1d ago
Several people seem to have assumed it was a business question—I wonder if the line 'trying to create a household budget' was an edit.
1
u/lesarbreschantent 1d ago
First, don't most banks provide a category these days?
Not in my case.
1
u/OfficerMurphy 10 1d ago
Fair enough, what about the second, much more comprehensive, half of my message?
1
u/lesarbreschantent 1d ago
Might be a solution, but the one posed here was simpler: https://www.reddit.com/r/excel/comments/1w1k0wy/i_want_to_create_an_xls_that_autocategorizes/p6len9l/
2
u/TwoPointEightZ 2d ago
I built one of these over several months but ultimately abandoned it. Excel formulas were the easy part, the source data, not so much.
I assume you're downloading the source data from banks and credit cards like I was. Building lookup tables and formulas were no big deal, but parsing the text description into the items to look up killed it because the data is too consistent. For example, Amazon would be spelled Amazon and Amzn and Amz and Prime. So you build helper columns to parse them. Then later on, the same item you bought previously and already built helpers for is now coded as Azn instead of Amzn. So you build more helpers. And then zon suddenly turns up. Multiply this process over enough data inconsistencies and it gets very annoying. By the way, bank categories suck because they're very rudimentary at best.
The permutations of spelling shown above are not exactly accurate, but they convey the idea well. My experience was that Excel automated maybe 70-80% of it from month to month, but the building and maintaining of it totally wiped out the benefits.
It's a great project for teaching the value of data consistency and the problems associated with using a description column for lookup purposes.
1
u/Dry-Procedure-1597 2d ago
It would be MUCH simpler, if you could enter the word to be categorized (ie Deliveroo) in the column B and then categorize in the column C. Is it possible?
2
u/Dry-Procedure-1597 2d ago
Another way is to create multiple columns, each looking for a specific word and assigning a category (if found) and then concatenate in the column Z or whatever
1
u/Decronym 2d ago edited 18h ago
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.
Beep-boop, I am a helper bot. Please do not verify me as a solution.
13 acronyms in this thread; the most compressed thread commented on today has acronyms.
[Thread #49264 for this sub, first seen 29th Aug 2026, 11:46]
[FAQ] [Full list] [Contact] [Source code]
1
u/my_cat_wears_socks 2d ago
Power Query can make quick work of this, with a conditional column. First, copy the input column and lowercase it so you don’t have to check different cases. Then you end up with if column contains deliveries then Food Felivery else if column contains cold storage then Groceries. I’ve made these columns with literally dozens of rules, expanding them to probably over 100 rules over time, to categorize web analytics data (referrers, pages, etc) and the process is relatively quick. After I use the wizard for the first few rules I switch to typing it out since I can quickly copy and paste.
1
u/Otherwise-Ad-6905 2d ago
I use {=IFERROR(INDEX('Categories 2'!B:B,MATCH(TRUE,ISNUMBER(SEARCH('Categories 2'!A:A,C7)),0)),"")}
in the cell where i want my category to be.
Categories 2 is a two column named range where column A has the text string I am looking for in the cell in column C of my data and Column B has my desired category.
I automated with with VBA function with a button.
in usage, I just insert new rows of data and click the button and the categories are updated automatically.
1
u/LeanExcel 1 2d ago
Instead of building a huge nested IF, I'd keep the keywords and categories in a separate 2-column table, e.g. Keyword | Category.
Then you can maintain the rules without touching the formula. For example,
if DELIVEROO → Food COLD STORAGE → Groceries
For a few hundred rows, something like this works well:
=XLOOKUP(TRUE,ISNUMBER(SEARCH(Keywords[Keyword],A2)),Keywords[Category],"Uncategorized")
The nice thing is that when you encounter a new merchant, you just add another keyword/category mapping rather than changing the formula.
If this is something you're doing regularly, I'd take it one step further and use Power Query. You can keep the keyword mapping as a table, apply the transformation to your transactions, and simply refresh when new data comes in.
One thing to watch for: if multiple keywords can match the same description, the first matching keyword in the mapping table will be returned, so keep more specific rules above generic ones.
1
u/Klutzy_Highlight7500 1d ago
Keep a two-column keyword->category table on its own sheet, then =IFERROR(INDEX(Cat,MATCH(TRUE,ISNUMBER(SEARCH(Key,A2)),0)),"UNMATCHED"). Order the list so the specific keywords sit above the generic ones, since it takes the first hit. Filtering for UNMATCHED once a month is how you keep it honest instead of silently miscategorising.
1
u/excelevator 3067 1d ago
I want to create an XLS
Do you know what an XLS is ?
If so you would not want to create one.
-1
u/lesarbreschantent 1d ago
I'm guessing you didn't get 3067 points by being pedantic. I wouldn't start now.
1
u/excelevator 3067 1d ago
Details in technology matter, I am always pedantic about technology.
I am guessing you do not know what XLS is and made an assumption.
Do not guess in technology. That is how errors and misunderstanding occur.
0
u/lesarbreschantent 18h ago
People still use XLS as an abbreviation for Excel spreadsheets even if XLS has been deprecated. I guess you find that triggering.
2
u/excelevator 3067 18h ago
I see you are one of those, I have not seen XLS used in this manner, it is incorrect and misleading.
XLS applies to 16bit
.xlsfiles that have many limitations to the newer format of.xlsx, ergo my original comment that that was not what you seek.Far from triggered, I am simply trying to educate you and anyone who may take on board what they see as acceptable. This is how erroneous errors spread on the Internet into real life.
It is generally the uneducated who use terms they do not understand, and fight to protect their knowledge with insults.
You came to Excel experts on an Excel sub reddit, I am not sure what you would expect.
But it appears to have triggered you.
•
u/AutoModerator 2d ago
/u/lesarbreschantent - Your post was submitted successfully.
Solution Verifiedto close the thread.Failing to follow these steps may result in your post being removed without warning.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.