Categorize Bank Transactions in Excel (Formulas + Template)

Auto-categorize a bank statement in Excel with a keyword rules table, one XLOOKUP or INDEX/MATCH formula, and a pivot table that turns it into a monthly P&L.

By Brenda Dankworth, CPA · Reviewed by Joel Palmeri, CPA · Updated · 3 min read

Key takeaways

  • Keep a separate Rules sheet that maps a keyword found in the description to a category. The formula just looks it up.
  • In Excel 365, one XLOOKUP with SEARCH categorizes every row. Older Excel versions can use INDEX and MATCH.
  • Order matters. Put specific keywords ("UBER *EATS") above general ones ("UBER").
  • A pivot table on the categorized sheet gives you spending by category and month in seconds.

If you track a business (or several) in spreadsheets, you can get most of the benefit of accounting software's bank rules with one formula and a small table. Paste in a statement, and every transaction gets a category; add a pivot table, and you have spending by category and month.

Download the categorization template (.xlsx)

The template has two sheets: Transactions (date, description, amount, category) and Rules (keyword, category). The examples below use its sample data.

Step 1: Get the transactions into one clean list

You need one row per transaction with a date, the bank's description and a signed amount (money in positive, money out negative). If you're starting from a PDF, see how to convert a bank statement to Excel, and run the balance check before you categorize.

Step 2: Build the rules table

On a sheet named Rules, list keywords that appear in descriptions and the category each one means:

Keyword (contains) Category
UBER *EATS Meals
UBER Car and truck
SQUARE INC Sales
GUSTO Payroll
SYSCO Cost of goods sold
PG&E Utilities
AMZN Office supplies
ADOBE Software
SPOTIFY Owner's draw
SHELL Car and truck

Keywords are matched anywhere in the description and aren't case-sensitive. Order matters: the formula returns the first rule that matches, so "UBER *EATS" must come before "UBER". For choosing the categories themselves, use how to categorize business expenses.

Step 3: The formula

Excel 365 and Google Sheets

In the Category column (D2), assuming descriptions are in column B:

=XLOOKUP(TRUE, ISNUMBER(SEARCH(Rules!$A$2:$A$100, B2)), Rules!$B$2:$B$100, "Uncategorized")

How it works: SEARCH looks for every keyword inside the description at once and returns a position or an error. ISNUMBER turns that into TRUE for matches. XLOOKUP returns the category for the first TRUE, or "Uncategorized" if nothing matched. Fill it down the column.

Older Excel versions

Without XLOOKUP, use INDEX and MATCH (this is what the template uses, so it works everywhere):

=IFERROR(INDEX(Rules!$B$2:$B$100,
  MATCH(TRUE, INDEX(ISNUMBER(SEARCH(Rules!$A$2:$A$100, B2)) * (Rules!$A$2:$A$100<>"") > 0, 0), 0)),
  "Uncategorized")

The (Rules!$A$2:$A$100<>"") part stops empty rows in the rules table from matching everything.

Step 4: Review the leftovers

Filter the Category column for Uncategorized. For each one, decide the category and, if the payee will come back, add a rule. After two or three months, almost everything categorizes itself. Anything you're unsure about can go to an "Ask my accountant" category for now.

Step 5: Turn it into a monthly P&L

  1. Add a Month column: =TEXT(A2, "yyyy-mm").
  2. Select the table and choose Insert → PivotTable.
  3. Drag Category to Rows, Month to Columns, and Amount to Values (Sum).
  4. Sort categories by total, or group income categories at the top.

Using Ortiz Catering's October sample data, the pivot looks like this:

Category 2026-10
Sales 3,482.15
Rent or lease −2,400.00
Payroll −1,840.00
Cost of goods sold −1,276.38
Utilities −412.67
Office supplies −84.99
Car and truck −63.21
Software −59.99
Owner's draw −11.99

Owner's draw isn't an expense, so leave it out of profit. Filter it out of the pivot, or keep it in a separate section. See owner's draw vs salary for why.

Common problems

Problem Fix
Everything returns "Uncategorized" Check the sheet name in the formula matches your rules sheet exactly
Wrong category for some rows A general keyword sits above a specific one; reorder the rules
#SPILL! in Excel 365 Something is in the cells below the formula; clear them, or the column isn't a table
Formula is slow Limit ranges to the rows you use (A2:A200), not whole columns
Transfers counted as income Add rules for "TRANSFER", "ONLINE TRANSFER" and your card autopay, categorized as Transfer

Bankly categorizes statements as it reads them, and learns from your corrections the same way a rules table does: change a payee once and it's filed that way on every statement after. When you're ready to move off spreadsheets, it syncs to QuickBooks Online.

Next: once each month is categorized, reconcile it, and make both part of your month-end close.

Frequently asked questions

Can Excel categorize transactions automatically?

Yes, with a rules table and a lookup formula. Each description is searched for the keywords in your rules, and the first match's category is returned. New statements are categorized as soon as you paste them in.

Does this work in Google Sheets?

Yes. Google Sheets supports XLOOKUP and SEARCH, so the Excel 365 formula works as written. You can also upload the template to Google Drive and open it with Sheets.

Why does my formula return the wrong category?

Usually because a shorter, more general keyword appears above a more specific one in the rules table, so it matches first. Move specific rules higher, or make keywords longer and more distinctive.

Keep reading