Search For 8 digit number after a substring in a row

sika14307

New Member
Joined
Feb 6, 2023
Messages
10
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi,

I am trying to create a public function that extract an eight digit number after a variation of the string, invoice number, in a row.

For example, if a row has "invoice rejection, po 90449033, invoice number 12345678", I want the function to extract only the invoice number.

The closest I was able to find is a function that counts the nearest 8 digit number in a row of text but not sure how to expand it to only extract the number after a certain phrase.

By variation of invoice number, I mean to extract the number after determining if it meets multiple options (inv or invoice number or invoice)
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
BAsed on your sample, this will work
Excel Formula:
=RIGHT(A1,8)
More sample data may give a clearer picture of what you actually need.
 
Upvote 0
You're going to have to specify the exact rules to determine what should be extracted. It can't just be "the 8-digit number after inv" or "invoice", as that might include the PO# in your referenced example.
 
Upvote 0
BAsed on your sample, this will work
Excel Formula:
=RIGHT(A1,8)
More sample data may give a clearer picture of what you actually need.
This is email data so the data isn't very clean. I am trying to get only invoice number.
 
Last edited by a moderator:
Upvote 0
You're going to have to specify the exact rules to determine what should be extracted. It can't just be "the 8-digit number after inv" or "invoice", as that might include the PO# in your referenced example.
Hey, I am using email data so I don't except to capture all the invoice number correctly. I am just trying to capture as much as possible, that why I want it to look for different variations of the word invoice.
 
Last edited by a moderator:
Upvote 0
This will work if the text "invoice number" is exactly the same in each instance, but I'm guessing it won't be.
Excel Formula:
=LOOKUP(10^10,MID(A1,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A1&1234567890,FIND("invoice number",A1))),{1,2,3,4,5,6,7,8,9})+0)
 
Upvote 1
Solution
This will work if the text "invoice number" is exactly the same in each instance, but I'm guessing it won't be.
Excel Formula:
=LOOKUP(10^10,MID(A1,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A1&1234567890,FIND("invoice number",A1))),{1,2,3,4,5,6,7,8,9})+0)
It is close enough thanks
 
Upvote 0
It is close enough thanks
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0
Alternative:
Code:
=IFERROR(MID(A2,SEARCH("invoice number",A2)+15,8)+0,"")
 
Upvote 0

Forum statistics

Threads
1,215,018
Messages
6,122,703
Members
449,093
Latest member
Mnur

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