Text lookup

ryansm05

Board Regular
Joined
Sep 14, 2016
Messages
148
Office Version
  1. 365
Platform
  1. Windows
Hi,

I need to create a formula that looks at the mid point of a cell =MID(CellA1,20,????) and starts at character 20 and returns the next 2 words before a space.

Cell A1 contains "AAAAAAAAAAAAAAAAAA RyanSmith Recruitment AFH 0967"
Cell A2 contains "AAAAAAAAAAAAAAAAAA JonBlot Recruitment AFH 0987"

Formula in cell A1 to return: RyanSmith Recruitment
Formula in cell A2 to return: JonBlot Recruitment

There will be hundreds of lines of data and the character count will vary. Therefore, I need the formula to start at character 20 and return the next two full words before a second space.

If anyone can help it'd be much appreciated.

Thanks
Ryan
 

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.
If they are always prefixed the same then try this formula:

TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),(2-1)*LEN(A1)+1,2*LEN(A1)))
 
Upvote 0
If they are always prefixed the same then try this formula:

TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),(2-1)*LEN(A1)+1,2*LEN(A1)))

This works great for the two examples I shared. However, the 'aaaaaaaaaaaaaaaaaa' may actually comprise of 2/3/4/5 words (there are a lot of variations) - and so I need the formula to ignore what's in front of it effectively and then start from character 20 if possible.

Do you think this can be achieved?

Thanks
Ryan
 
Upvote 0
Ahh OK that shouldn't be too much of a problem then as they all start at the 20th character, try:

=TRIM(LEFT(SUBSTITUTE(MID(A1,20,LEN(A1))," ",REPT(" ",LEN(A1))),2*LEN(A1)))
 
Upvote 0
Another idea:

=LEFT(REPLACE(A1,1,19,""),FIND(" ",A1,FIND(" ",A1,21)+1)-20)
 
Upvote 0
Ryan
It is always a good idea to be realistic in the variety of sample data that you provide. You have now told us that there can be several 'words' in that first 19 characters but what about the last part? In your two samples they both have exactly 4 'words' after the 19th character and exactly 9 characters after the two words you want to extract. If that was consistent then this would suffice.

=MID(A1,20,LEN(A1)-28)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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