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.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hey,

How about COUNTIF using wildcards?

E.g. =COUNTIF($A$1:$A$10,"*BMW*") will return how many cells in the range A1:A10 that CONTAIN "BMW"
 
Last edited:
Upvote 0
OK,

Is the reference number always numeric? I.e. =ISNUMBER(references) always returns TRUE?
 
Upvote 0
try
Code:
=IF(ISNUMBER(SEARCH("bmw",A2)),B2,"")

how many narratives are there?
and do you want to search for the narratives at the same time?
 
Last edited:
Upvote 0
We get about 150 statement lines every day, each is a payment from a customer. The list of key words is 2000+, one for each of our 2000+customers.

I need to see if any of the 2000+ key words appears in the statement narrative, if it does then I need to return a customer reference associated with that key word.

So for line 1 on the statement I need to look at the 2000+key words and see if any of them appear in the narrative (and return the relevant cust ref if it does)
Then for line 2 on the statement I need to look at the 2000+key words and see if any of them appear in the narrative (and return the relevant cust ref if it does)
then for line 3 on the statement I need to look at the 2000+key words and see if any of them appear in the narrative (and return the relevant cust ref if it does)
and so on...

If there is a way to add screen shots or an attachment that might help as they say a picture is worth a thousand words.
 
Last edited:
Upvote 0
If there is a way to add screen shots or an attachment that might help as they say a picture is worth a thousand words.

yes i think i get the idea but you can use HTML Maker and other tools to attach what you're talking about.
but as i understand you need an array formula that says if ANY of these 2000+ keywords are found, return the value for column B (the customer ref number)? I would suggest these things:

1. make the keywords a named range on another sheet
2. post your screenshot of what you currently have
3. post your screenshot of what you expect it to look like

& then i'll make a formula that meets what you need, but i don't want to start and it end up being not what you're explicitly asking for.
 
Upvote 0
I believe it can be done with SUMPRODUCT if the cust ref number is numerical only, otherwise a different approach is required.

Are the reference numbers numerical or alphanumerical?

ABCDE
1Invoice for Vauxhall123BMW1738
2Audi Repair9215Audi9215
3BMW Repairs1738Jaguar1983
4Jaguar Repairs1983Vauxhall123

<tbody>
</tbody>


If numerical you can get this using formula in B1 and dragged down:
Code:
SUMPRODUCT((ISNUMBER((SEARCH($D$1:$D$4,A1))))*($E$1:$E$4))
 
Last edited:
Upvote 0
Apologies for the length of the reply before we begin.

I have created some sample data below. Each table is on a different tab in the same workbook.
The first table shows the list of key words and the corresponding customer reference. I have named the range A1:B9 as "key".

AB
1Key wordCust ref
2AlfaCUS-001
3AstonCUS-002
4BMWCUS-003
5FordCUS-004
6HondaCUS-005
7MercedesCUS-006
8NissanCUS-007
9VauxhallCUS-008

<tbody>
</tbody>

The second table shows the narrative that appears on the bank statement (column A).

The formula needs to go in column B and I have put the answer I would expect to receive in this column. Any blanks are where there is no match to a key word (ie there is no "A Romero", no "Merc" but there is "Mercedes", no "vaux" but there is "vauxhall", no "Nisan")



AB
1Statement narrativeCustomer ref
2BMW motors uk ltdCUS-003
3Ford motor companyCUS-004
4general motors (vauxhall)CUS-008
5Nissan (Feb invoice)CUS-007
6Aston Martin Motor coCUS-002
7A Romeo
8Merc Benz
9Ford (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

<tbody>
</tbody>


The formula would read something like:
lookup the statement narrative in cell A1 (BMW motors uk Ltd), if any of the key words in the named range "key" appear in cell A1 (BMW does appear), then return the cust ref for that key word (in this case CUS-003).

the next line would read
lookup the statement narrative in cell A2 (Ford motor company), if any of the key words in the named range "key" appear in cell A2 (Ford does appear), then return the cust ref for that key word (in this case CUS-004).
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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