Return Everything before a string plus additional two " "s

Veleric

New Member
Joined
Oct 14, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am trying to return everything before a specific string as well was the next two spaces or more specifically the next text string following.

Example: JASON THOMPSON 123 MAIN ST PO BOX 184 NOWHEREVILLE ID 46582
Parameters: Searching for string "PO BOX" (with or without spaces depending on formula)
Desired Output: JASON THOMPSON 123 MAIN ST PO BOX 184

The location of the searched string (in this case PO BOX) is not predictable, so it can't be set at a specific location or number of spaces or anything, it needs to be able to change according to the record/cell data.

The above request is the most important part, but I would also really appreciate the ability to pull this from the right side as well, so "PO BOX 184 NOWHEREVILLE ID 46582"

Please let me know if further information is required.

Thanks!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
First request:
Excel Formula:
=MID(A1,FIND("PO BOX",A1),FIND(" ",A1,FIND("PO BOX",A1)+7)-FIND("PO BOX",A1))
Second request:
Excel Formula:
=MID(A1,FIND("PO BOX",A1),LEN(A1))

Edit: I misread the first request, thought you just wanted the PO BOX info. To get the text from the left through the PO BOX info, try:
Excel Formula:
=LEFT(A1,FIND(" ",A1,FIND("PO BOX",A1)+7)-1)
 
Upvote 0
Solution

Forum statistics

Threads
1,215,544
Messages
6,125,441
Members
449,225
Latest member
mparcado

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