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>
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

István Hirsch

Well-known Member
Joined
May 16, 2013
Messages
1,634
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
 

azumi

Well-known Member
Joined
Jun 4, 2013
Messages
555
=trim(left(substitute(substitute(substitute(substitute(substitute(substitute(substitute(a1,"&"," "),"*"," "),"_"," "),"#"," "),"@"," "),"-"," ")," ",rept(" ",100)),200))
 

Watch MrExcel Video

Forum statistics

Threads
1,123,158
Messages
5,600,054
Members
414,357
Latest member
Gemma_R

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
Top