A function similar to vlookup, but matching on partial values.

SerenityNetworks

Board Regular
Joined
Aug 13, 2009
Messages
131
Office Version
  1. 365
Platform
  1. Windows
I am trying to assign categories to our monthly financial transactions. I download the transactions from our banks and credit cards, then import them into a workbook. I'll see transactions like the following:
Description
EMPIRE DISTRICT ELEC BILL 220906 35849771 LastName
EMPIRE DISTRICT ELEC BILL 221005 35849771 LastName
EMPIRE DISTRICT ELEC BILL 221107 35849771 LastName
EMPIRE DISTRICT ELEC BILL 221205 35849771 LastName
TANEY COUNTY REG Utilities, Sewer 220118 703568 LASTN
TANEY COUNTY REG Utilities, Sewer 220217 703568 LASTN
TANEY COUNTY REG Utilities, Sewer 220317 703568 LASTN
VENMO PAYMENT 220912 1022310974417 ANDREW LASTN
VENMO PAYMENT 220926 1022557429615 ANDREW LASTN
VENMO PAYMENT 220928 1022604113014 ANDREW LASTN
SSA TREAS 310 XXSOC SEC 011222 XXXXX0381A SSA LASTNM
SSA TREAS 310 XXSOC SEC 011222 XXXXX4328A SSA LASTNF
SSA TREAS 310 XXSOC SEC 020922 XXXXX0381A SSA LASTNM
SSA TREAS 310 XXSOC SEC 020922 XXXXX4328A SSA LASTNF
BROKERAGE 220301 6369V49702722 LASTN
BROKERAGE 220330 6369V49702722 LASTN
BROKERAGE 220202 6369V49702722 LASTN
220205 Transfer to Savings
220305 Transfer to Savings

You'll note that there are base similarities for each transaction. Sometimes the date creates the difference and sometimes it is a date and/or transaction number. I'd like to trim it down to base descriptions, like the following, and have them in a separate worksheet with Group and Detail values.
DescriptionGroupDetail
EMPIRE DISTRICT ELEC BILLPurchaseUtilities, Electric
TANEY COUNTY REG Utilities, SewerPurchaseUtilities, Sewer
VENMO PAYMENTPurchaseVARIES
SSA TREAS 310 XXSOC SECIncomeIncome, Soc Sec
BROKERAGEIncomeIncome, Disbursement
Transfer to SavingsTransferTransfer

Then the next time I import a bunch of transactions import a bunch of transactions into the workbook, for each transaction (as in the first table) I'd like to be able to return the Group and Detail values. The vlookup, match, lookup, and similar functions don't seem to work, as the length of what I'm looking up varies and doesn't always start at the left.

I'd love some input on how I might accomplish my goal. I'm having a brain cramp on a solution.

Thanks in advance,
Andrew
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
what I'm looking up varies and doesn't always start at the left.
all your examples start on the left, except the savings which seems to be the right - so using an IF and left/right - could probably do that easier

find the 1st 6 numbers in a string and provide the LEFT part - UNLESS the string starts with a 6 digit number and then provide the right part

What version of excel do you have - because in the later version 365 , we have a lot of additional text functions - like textsplit , textbefore, textafter
which may make this easier to do

can you give more examples of the text - because at the moment it looks like , if there is a date (number ) for the 1st 6 digits - then use RIGHT()
otherwise find the first 6 digit number n the text and then use LEFT()
so a textbefore() and textafter() would work well

OR LEFT / RIGHT with an iferror
if the example above is the only variables

=IFERROR(LEFT(A1,FIND("------",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"0","-"),"1","-"),"2","-"),"3","-"),"4","-"),"5","-"),"6","-"),"7","-"),"8","-"),"9","-"))-2),RIGHT(A1,LEN(A1)-7))

Book1
ABD
1EMPIRE DISTRICT ELEC BILL 220906 35849771 LastNameEMPIRE DISTRICT ELEC BILL
2EMPIRE DISTRICT ELEC BILL 221005 35849771 LastNameEMPIRE DISTRICT ELEC BILL
3EMPIRE DISTRICT ELEC BILL 221107 35849771 LastNameEMPIRE DISTRICT ELEC BILL
4EMPIRE DISTRICT ELEC BILL 221205 35849771 LastNameEMPIRE DISTRICT ELEC BILL
5TANEY COUNTY REG Utilities, Sewer 220118 703568 LASTNTANEY COUNTY REG Utilities, Sewer
6TANEY COUNTY REG Utilities, Sewer 220217 703568 LASTNTANEY COUNTY REG Utilities, Sewer
7TANEY COUNTY REG Utilities, Sewer 220317 703568 LASTNTANEY COUNTY REG Utilities, Sewer
8VENMO PAYMENT 220912 1022310974417 ANDREW LASTNVENMO PAYMENT
9VENMO PAYMENT 220926 1022557429615 ANDREW LASTNVENMO PAYMENT
10VENMO PAYMENT 220928 1022604113014 ANDREW LASTNVENMO PAYMENT
11SSA TREAS 310 XXSOC SEC 011222 XXXXX0381A SSA LASTNMSSA TREAS 310 XXSOC SEC
12SSA TREAS 310 XXSOC SEC 011222 XXXXX4328A SSA LASTNFSSA TREAS 310 XXSOC SEC
13SSA TREAS 310 XXSOC SEC 020922 XXXXX0381A SSA LASTNMSSA TREAS 310 XXSOC SEC
14SSA TREAS 310 XXSOC SEC 020922 XXXXX4328A SSA LASTNFSSA TREAS 310 XXSOC SEC
15BROKERAGE 220301 6369V49702722 LASTNBROKERAGE
16BROKERAGE 220330 6369V49702722 LASTNBROKERAGE
17BROKERAGE 220202 6369V49702722 LASTNBROKERAGE
18220205 Transfer to SavingsTransfer to Savings
Sheet1
Cell Formulas
RangeFormula
D1:D18D1=IFERROR(LEFT(A1,FIND("------",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"0","-"),"1","-"),"2","-"),"3","-"),"4","-"),"5","-"),"6","-"),"7","-"),"8","-"),"9","-"))-2),RIGHT(A1,LEN(A1)-7))
 
Last edited:
Upvote 0
Brilliant! Thank you. I hadn't thought to use the substitute function to assist with the trimming. But I see my examples left a lot to be desired. Your trimming captured about a third of my actual transactions, which is still a significant help. Below are some examples of what was missed and what I'd prefer my trimmed values to be. If possible, I'd prefer it not to be case sensitive. That said, I'm sure open to keeping within some rules on my manually trimmed values (like putting numbers and/or special characters within quotes, or not allowing numbers at all), and I'm sure open to just letting the formula throw a "CHECK ME" value when it runs across something that doesn't fit the convention.

I am using Microsoft Excel for Microsoft 365 MSO, so functions like textsplit and textbefore are supported. (I used to be adept at Excel, but it looks like a lot has come along since my retirement and ceasing to keep current.)

Thanks again for the help. This task is way beyond my current ability.

Downloaded Transaction Descriptionetaf's trimmingtrimmed preference
18 INDUSTRIAL PARK DHOLLISTER, MOSTRIAL PARK DHOLLISTER, MO18 INDUSTRIAL PARK DHOLLISTER, MO
Amazon.com*5V4V696K3com*5V4V696K3Amazon.com
Amazon.com*7Q15C5DJ3com*7Q15C5DJ3Amazon.com
AMZN Mktp US*VG8IP9PY3tp US*VG8IP9PY3AMZN Mktp US
ARBY'S 566566ARBY
AT&T *PAYMENTT *PAYMENTAT&T *PAYMENT
ATT*BILL PAYMENTL PAYMENTATT*BILL PAYMENT
AUTOMATIC PAYMENT - THANKIC PAYMENT - THANKAUTOMATIC PAYMENT - THANK
BATTLEFIELD MALL SPRINGFIELD MO (P9119002400YY5D5E)BATTLEFIELD MALL SPRINGFIELD MO (BATTLEFIELD MALL
BEACH 5263263BEACH
BIG D'S BBQ BRANSON Branson, MOBBQ BRANSON Branson, MOBIG D'S BBQ
BRANSON MEADOWS CINEMAMEADOWS CINEMABRANSON MEADOWS CINEMA
CBI*ASHAMPOOAMPOOCBI*ASHAMPOO
CBN DONATIONATIONCBN
PURCHASE AUTHORIZED ON 02/02 CBN DONATION 757-226-3334 VA S463033401913091 CARD 2004PURCHASE AUTHORIZED ON 02/02 CBN DONATIONCBN
CHECK # 9061 (BCCA)9061 (BCCA)CHECK
CHECK # 9063 (Stormy Point Village)9063 (Stormy Point Village)CHECK
COSTCO WHSE #1486WHSE #1486COSTCO WHSE
COUNTRY MART #70MART #70COUNTRY MART
COUNTRY MART HOLLISTER, MOMART HOLLISTER, MOCOUNTRY MART
******* BARREL #274 PEARLBARREL #274 PEARL******* BARREL
******* BARREL #557 SPANIBARREL #557 SPANI******* BARREL
FIDELITY LIFE ASSOCIATIONY LIFE ASSOCIATIONFIDELITY LIFE ASSOCIATION
GOODWILL OZARKL OZARKGOODWILL
INTEREST PAYMENTT PAYMENTInterest Payment
Interest Paymentt PaymentInterest Payment
MENARDS HOLLISTER MOHOLLISTER MOMENARDS
MENARDS HOLLISTER MOHOLLISTER, MOHOLLISTER MOHOLLISTER, MOMENARDS
MOBILE DEPOSIT : REF NUMBER :315110469806MOBILE DEPOSIT : REF NUMBERMOBILE DEPOSIT
MONTHLY MAINTENANCE FEEMAINTENANCE FEEMONTHLY MAINTENANCE FEE
MONTHLY MAINTENANCE FEE WAIVEDMAINTENANCE FEE WAIVEDMONTHLY MAINTENANCE FEE
NEW YORK LIFE INS. PREM. FEB 23 C4740002 NAMENEW YORK LIFE INS. PREM. FEB 23NEW YORK LIFE INS. PREM.
NEW YORK LIFE INS. PREM. JAN 23 C4740002 NAMENEW YORK LIFE INS. PREM. JAN 23NEW YORK LIFE INS. PREM.
ONLINE PAYMENT - THANK YOUPAYMENT - THANK YOUONLINE PAYMENT
ONLINE PAYMENT THANK YOUPAYMENT THANK YOUONLINE PAYMENT
ONLINE PAYMENT, THANK YOUPAYMENT, THANK YOUONLINE PAYMENT
Online Payment, Thank youPayment, Thank youONLINE PAYMENT
ONLINE TRANSFER FROM LINDSAY A SAVINGS XXXXXXXXX2783 REF #IB0HBJC6K2 ON 12/31/22TRANSFER FROM LINDSAY A SAVINGS XXXXXXXXX2783 REF #IB0HBJC6K2 ON 12/31/22ONLINE TRANSFER
ONLINE TRANSFER REF #IB0HD4THK4 TO PERSONAL LINE OF CREDIT XXXXXX8909 ON 01/06/23TRANSFER REF #IB0HD4THK4 TO PERSONAL LINE OF CREDIT XXXXXX8909 ON 01/06/23ONLINE TRANSFER
OVERDRAFT XFER FROM CREDIT CARD OR LINEFT XFER FROM CREDIT CARD OR LINEOVERDRAFT XFER FROM CREDIT CARD OR LINE
PETCO 1669 63516694PETCO 1669PETCO
PILOT 00015503PILOTPILOT
Prime Video *1V29C7FW3ideo *1V29C7FW3Prime Video
Prime Video *HP3038EO1ideo *HP3038EO1Prime Video
RECURRING TRANSFER FROM NAME CHECKING REF #OP0HQZWSQQ XXXXXX4321NG TRANSFER FROM NAME CHECKING REF #OP0HQZWSQQ XXXXXX4321RECURRING TRANSFER FROM
RECURRING TRANSFER FROM NAMECHECKING REF #OP0HVJ5BD8 XXXXXX4321NG TRANSFER FROM NAMECHECKING REF #OP0HVJ5BD8 XXXXXX4321RECURRING TRANSFER FROM
RECURRING TRANSFER TO NAME SAVINGS REF #OP0HC7LF69 XXXXXXXXX1234NG TRANSFER TO NAME SAVINGS REF #OP0HC7LF69 XXXXXXXXX1234RECURRING TRANSFER TO
RECURRING TRANSFER TO NAME SAVINGS REF #OP0HGWGSNR XXXXXXXXX1234NG TRANSFER TO NAME SAVINGS REF #OP0HGWGSNR XXXXXXXXX1234RECURRING TRANSFER TO
SQ *RILEY'S TREASURE THRIEY'S TREASURE THRIRILEY'S TREASURE
SQ *RILEY'S TREASURE THRIEY'S TREASURE THRIRILEY'S TREASURE
ROYAL CARIBBEAN CRUISESARIBBEAN CRUISESROYAL CARIBBEAN CRUISES
STATE FARM RO 27 SFPP 14 S 120311111 XSTATE FARM RO 27 SFPP 14 SSTATE FARM RO
STATE FARM RO 27 SFPP 14 S 120311111 NAMESTATE FARM RO 27 SFPP 14 SSTATE FARM RO
STORE # 0351 BRANSON MO (P9356000400Y3J7N8)STORE # 0351 BRANSON MO (STORE # 0351 BRANSON MO
STORE # 0351 BRANSON MO (P9356001400Y3B2QE)STORE # 0351 BRANSON MO (STORE # 0351 BRANSON MO
Subway 1365613656Subway
TST* Mr Gilbertis PlaceGilbertis PlaceMr Gilbertis Place
TUESDAY MORNING # 0837MORNING # 0837TUESDAY MORNING
TUESDAY MORNING # 0874MORNING # 0874TUESDAY MORNING
UNITED WORLD HTH FEB INSPRM 230201 R211J54 NAME2UNITED WORLD HTH FEB INSPRMUNITED WORLD HTH
UNITED WORLD HTH JAN INSPRM 230103 R211J54 NAME2UNITED WORLD HTH JAN INSPRMUNITED WORLD HTH
WHT RVR FSH HS - BRANSONFSH HS - BRANSONWHT RVR FSH HS
WOODHILLS.ORGLS.ORGWOODHILLS.ORG
 
Last edited:
Upvote 0
thanks for the reply
mmm a lot more complex as you have alpha numeric - some with * some with # and not all extracted

for example
18 INDUSTRIAL PARK DHOLLISTER, MO
is not extracted
some *v or *5

for example
STORE # 0351 BRANSON MO (P9356000400Y3J7N8)
ignores the # and number - bit goes for 2nd number

I will need to think about this, but not around for a few days now - so hopefully another member will answer

Clearly the IFERROR , does not work
 
Upvote 0
I will need to think about this, but not around for a few days now - so hopefully another member will answer
Thanks. I'll ponder on it as well, and consider learning about those new text string functions.
 
Upvote 0
thanks , and perhaps any rules that can be applied to the string - maybe a VBA solution (which i do not provide on forums) may be the way to go in the end
 
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

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