How to extract word upto specified word by single formula?

London12F

Board Regular
Joined
Jun 21, 2016
Messages
59
How to extract words upto specified word ("Co ", "Eng", "Construction", "(") by single formula (not by VBA)(not by array formula)?
 
i.e.
 
ABC DE Co Ltd
FGH IJ KL Eng Co Ltd
ABC Construction Ltd
ABC (China) Co Ltd
to
ABC DE
FGH IJ KL
ABC
ABC

<colgroup><col></colgroup><tbody>
</tbody>
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
How to extract words upto specified word ("Co ", "Eng", "Construction", "(") by single formula (not by VBA)(not by array formula)?
That is a lot of restrictions for a text string manipulations problem. Is there a maximum length to the text that can be in a cell?
 
Upvote 0
There is no maximum length to the text, but it should be upto 3 words.
Then I am pretty sure there is no way to do this with a normally entered formula... and I am reasonably sure that any array-entered formula is going to be "ugly" at best. While you don't want a VBA solution, I am going to post one for future readers of this thread (you will have to wait for someone better versed in formulas than I am to try and give you what you have asked for). The following function can be called from other VBA code or used as a UDF (user defined function) within an Excel formula...
Code:
Function UpperCaseWords(S As String) As String
  Dim X As Long
  For X = 1 To Len(S)
    If Mid(S, X, 1) Like "[a-z]" Then
      UpperCaseWords = Left(S, InStrRev(Left(S, X), " ") - 1)
      Exit Function
    End If
  Next
End Function
The above function pulls out upper case words up to, but not including, the first word with a lower case letter in it.
 
Last edited:
Upvote 0
Does this satisfy?

In B2 enter and copy down:

=TRIM(LEFT(A2,LOOKUP(9.99999999999999E+307,SEARCH(" "&{"co*","(*","eng"}&" "," "&A2&" "))-1))
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,871
Members
449,097
Latest member
dbomb1414

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