Insert partial filename in cell A1

ZzaqpazZ

New Member
Joined
Oct 23, 2014
Messages
5
I need a way to insert the part of the file name after PO.
In the example below, 3351 is the work order number, between brackets is the customer name, then the description and then the PO number.
The problem is the PO number varies in length and could contain digits, dashes etc. so I need to return everything past PO .

Example;
3351 (Customer Name) Wave Guide Support - PO 2245

Should return the value 2245 in cell A1.

Any help would be appreciated
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
You could do it this wayExcel 2010
AB
13351 (Customer Name) Wave Guide Support - PO 22452245

<colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /></colgroup><thead>
</thead><tbody>
</tbody>
Sheet5

Worksheet Formulas
CellFormula
B1=MID(A1,FIND(" ",A1,FIND("PO",A1))+1,100)

<thead>
</thead><tbody>
</tbody>
 
Upvote 0
You could do it this wayExcel 2010
AB
13351 (Customer Name) Wave Guide Support - PO 22452245

<tbody>
</tbody>
Sheet5

Worksheet Formulas
CellFormula
B1=MID(A1,FIND(" ",A1,FIND("PO",A1))+1,100)

<tbody>
</tbody>

<tbody>
</tbody>

Hi Momentman,
This formula implies that the file name be in one of the cells but I am trying to pull the values directly from the name of the file.
I also want to make sure not to return (.xlsx).
Thanks for your help.
 
Upvote 0
Ok, its the filename right? then maybe

Excel 2010
A
12245
Sheet5
Cell Formulas
RangeFormula
A1=TRIM(RIGHT(SUBSTITUTE(REPLACE(CELL("filename"),FIND(".",CELL("filename")),100,"")," ",REPT(" ",99)),99))
 
Upvote 0
Ok, its the filename right? then maybe
Excel 2010
A
12245

<colgroup><col style="width: 25pxpx"><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet5

Worksheet Formulas
CellFormula
A1=TRIM(RIGHT(SUBSTITUTE(REPLACE(CELL("filename"),FIND(".",CELL("filename")),100,"")," ",REPT(" ",99)),99))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Works perfect!!!
Thank you
 
Upvote 0
You are welcome. Thanks for the feedback

Hi Momentman,
A new problem has arisen from this formula.
Some of our client have initials (with a period) in their names which cause the wrong value to return in cell B1.
If I enter the file name 3351 (Customer Name) Wave Guide Support - PO 2245,
It returns 2245 as it should but...
If I enter the file name 3351 (Customer. Name) Wave Guide Support - PO 2245,
it returns (Customer

So it appears using a period in the file name creates a problem.
Any thoughts?
I'm not sure there is a solution to this as I think the period should represent the end of the name and so reading everything between PO and the period.
If it helps, the PO numbers are never longer that 20 or so digits at the most.

Any suggestions would be appreciated.
Thanks,
Martin
 
Upvote 0
It might be nice to have more possible examples just to be sure this formula covers all cases.

Am certain better formulas exist but here,


Excel 2010
B
12245
Sheet1
Cell Formulas
RangeFormula
B1=MID(CELL("filename"),FIND("- PO ",CELL("filename"))+5,FIND(".xl",CELL("filename"))-FIND("- PO ",CELL("filename"))-5)
 
Upvote 0
That works perfectly.
I also tried whatever scenario I thought might come up and it works in every instance I tried.
Thanks again for your help.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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