return value if cell contains specific text

little jimmy

New Member
Joined
Mar 21, 2013
Messages
13
Hi,

I am trying to automate a way of searching through my bank statement and returning a reference number based on the narrative that appears on the statement (sample data attached). We get hundreds of items every day and the narrative that is quoted on the bank statement is always different (often due to different invoice number being quoted), BUT there will always be certain "key" text that is always quoted.

eg BMW will always be quoted, but the statement line may state "BMW motors" or "BMW july" payment or "Invoice for BMW"

I have a list of the "key" text and the relevant reference number that is needed for our Ledger system.

I need a formula that will look at each bank statement line, search the list of key text and return the relevant ref number.


If I were to write out the formula it would read something like "look at the first line on the bank statement (cell A2), if the narrative quoted contains a key word from column A of the the named range, then return the customer ref from column B of the named range into cell C2, if the narrative does not contain a key word then leave C2 blank. Repeat this for every statement line.

I have created a simplified mock up in excel but not sure how to attach a screen shot to this thread.

I have tried using =if(isnumber(search(.... but cannot figure it out.

Many thanks.
 
Hey,

Try the following:

B2:
Code:
IFERROR("CUS-00"&IF(SUMPRODUCT((ISNUMBER((SEARCH(KeyTab!$A$2:$A$9,A2))))*(VALUE(MID(KeyTab!$B$2:$B$9,FIND("-",KeyTab!$B$2:$B$9)+1,99))))=0,1/0,SUMPRODUCT((ISNUMBER((SEARCH(KeyTab!$A$2:$A$9,A2))))*(VALUE(MID(KeyTab!$B$2:$B$9,FIND("-",KeyTab!$B$2:$B$9)+1,99))))),"")

Change the 6 cases of "KeyTab" to the name of the tab containing the key data.
 
Last edited:
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I have created some sample data below. Each table is on a different tab in the same workbook.

Hi, another option to try to adapt to your two sheet set-up.


Excel 2013/2016
ABCDE
1Key wordCust refStatement narrativeCustomer ref
2AlfaCUS-001BMW motors uk ltdCUS-003
3AstonCUS-002Ford motor companyCUS-004
4BMWCUS-003general motors (vauxhall)CUS-008
5FordCUS-004Nissan (Feb invoice)CUS-007
6HondaCUS-005Aston Martin Motor coCUS-002
7MercedesCUS-006A Romeo
8NissanCUS-007Merc Benz
9VauxhallCUS-008Ford (inv ref 5927)CUS-004
10Nissan MotorsCUS-007
11GM Motors (vaux)
12BMW ukCUS-003
13Nissan motorsCUS-007
14Mercedes Benz ref 2330dCUS-006
15Ford (USA) IncCUS-004
16Vauxhall vehicle salesCUS-008
17Honda - JapanCUS-005
18Ford (inv ref 3009)CUS-004
19Nisan motors
20BMW (July 2019)CUS-003
21
Sheet1
Cell Formulas
RangeFormula
E2=IFERROR(LOOKUP(2,1/ISNUMBER(SEARCH($A$2:$A$9,D2)),$B$2:$B$9),"")
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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