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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
You could do it this wayExcel 2010
AB
3351 (Customer Name) Wave Guide Support - PO 2245

<colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"]2245[/TD]

</tbody>
Sheet5

Worksheet Formulas

<thead>
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]

</thead><tbody>
[TH="width: 10px, bgcolor: #DAE7F5"]B1[/TH]
[TD="align: left"]=MID( A1,FIND(" ",A1,FIND("PO",A1))+1,100 )

</tbody>
[/TD]
 
Upvote 0
You could do it this wayExcel 2010
AB
3351 (Customer Name) Wave Guide Support - PO 2245

<tbody>
[TD="align: center"]1[/TD]

[TD="align: right"]2245[/TD]

</tbody>
Sheet5

Worksheet Formulas
Cell

<tbody>
[TH="align: left"]Formula[/TH]

[TH="bgcolor: #DAE7F5"]B1[/TH]
[TD="align: left"]=MID( A1,FIND(" ",A1,FIND("PO",A1))+1,100 )

<tbody>

</tbody>
[/TD]

</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

<colgroup><col style="width: 25pxpx"><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"]2245[/TD]

</tbody>
Sheet5

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]A1[/TH]
[TD="align: left"]=TRIM(RIGHT(SUBSTITUTE(REPLACE(CELL("filename"),FIND(".",CELL("filename")),100,"")," ",REPT(" ",99)),99))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

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,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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