Text function Query

vksharma00001

Board Regular
Joined
Jun 9, 2014
Messages
116
Hi Experts

I have a data like this:

Killians Self Retaining Nasal Speculum
Suspension Laryngoscope
Tonsillar Snare-Eves
Micro Scissor Scissors

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

I want a dynamic formula in excel so that i can extract 1st and 2nd word. Special character can be anything like this "-"," ","@",# etc.

I want Output like this:

Killians Self
Suspension Laryngoscope
Tonsillar Snare
Micro Scissor

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

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Copy this into an empty Module then try the UDF:

Code:
Function ExtractFirstTwoWords(c As String) As String
    With CreateObject("VBScript.RegExp")
        .ignorecase = True
        .Global = True
        .Pattern = "^([a-z]+[ ][a-z]+)|.+?"
        If .Test(c) Then ExtractFirstTwoWords = .Replace(c, "$1")
    End With
End Function
 
Upvote 0
=trim(left(substitute(substitute(substitute(substitute(substitute(substitute(substitute(a1,"&"," "),"*"," "),"_"," "),"#"," "),"@"," "),"-"," ")," ",rept(" ",100)),200))
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,755
Members
449,094
Latest member
dsharae57

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