Text to Column

hardeep.kanwar

Well-known Member
Joined
Aug 13, 2008
Messages
693
Hello

I have Data Mentioned Below


Excel Workbook
BC
3NamesExpected Result
4Abhay Agarwal Pg-Bus 2010Abhay Agarwal
5Archit Vardharajan Pg Bus 2010Archit Vardharanjan
6Awninder Pg-Bus 2010Awninder
7Ayush Agrawal Pg Bus 2010Ayush Agrawal
8BHARVI JOSHI PG BUS 2010*
9Faizan Lokhandwala Pg Bus 2010*
10Hardik Upadhyay *PG-BUS, 2010*
11HEMANG KUMAR BORICHA PG-BUS. 2010*
12JAYESH SUTHAR PG-BUS. 2010*
13Jobin Thomas Pg Bus 2010*
14PERSIS ANTHONY PG-Media. 2010*
15Riddhima Kotwani PG-Bus 2010*
16SUKHDEV SINGH CHANNE PGDBM 2010*
17Sumeet Anand Pg Bus 2010*
18Vidhi Mundra PGDBE June 2010*
19Akhil Giri PG Media 2010 Pune Campus*
20Divyesh Chauhan Pdbm 2010*
21Kaushik Pg-Bus 2010*
22Kushan Mistry Pd-Bus 2010*
23Sajan Shrimali Pg-Bus 2010*
24Divya Shobhawat- Pt Media - 2010*
Ahmd


Some have Like this

Excel Workbook
B
4Jayant PDBM 2010
5Ajay PGDBE 2010
6ASHUTOSH VYAS 2010
7MANJEET SINGH PDBM 2010
8Neha Arora Ug Course 2010
9PARVEEN KUMAR PDBM 2010
10RAJAT GUPTA PDBM 2010
11RAJESH KUMAR SHARMA PDBM 2010
12Ranbir Singh PDBM 2010
13Ritika Vaid Pdbm 2010
14Robin Pdbm 2010
15Samridhi Sharma Pdbm 2010
Chd





Now , I want to Exact the Only Names from this Data

Any Idea How can i do it?

Thanks in Advance
 
Last edited:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try this

Code:
Sub xtract_Name()
Dim s As String
Dim LR As Long
LR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row 'get last row column A
For i = 2 To LR
    s = LCase(Cells(i, 1))
    If InStrRev(s, "pg") > 0 Then
        Cells(i, 2) = StrConv(Left(s, InStrRev(s, "pg") - 1), vbProperCase)
    End If
    If InStrRev(s, "pd") > 0 Then
        Cells(i, 2) = StrConv(Left(s, InStrRev(s, "pd") - 1), vbProperCase)
    End If
Next i
MsgBox "Done"
End Sub
 
Upvote 0
Try this

Code:
Sub xtract_Name()
Dim s As String
Dim LR As Long
LR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row 'get last row column A
For i = 2 To LR
    s = LCase(Cells(i, 1))
    If InStrRev(s, "pg") > 0 Then
        Cells(i, 2) = StrConv(Left(s, InStrRev(s, "pg") - 1), vbProperCase)
    End If
    If InStrRev(s, "pd") > 0 Then
        Cells(i, 2) = StrConv(Left(s, InStrRev(s, "pd") - 1), vbProperCase)
    End If
Next i
MsgBox "Done"
End Sub

Thanks Texasalynn

This Helps me Lot

Thanks Again
 
Upvote 0
Hi hardeep.kanwar,

An option with formula could be
Copy down the formula in B2:

Excel Workbook
AB
1Names
2Abhay Agarwal Pg-Bus 2010Abhay Agarwal
3Archit Vardharajan Pg Bus 2010Archit Vardharajan
4Awninder Pg-Bus 2010Awninder
5Ayush Agrawal Pg Bus 2010Ayush Agrawal
6BHARVI JOSHI PG BUS 2010BHARVI JOSHI
7Faizan Lokhandwala Pg Bus 2010Faizan Lokhandwala
8Hardik Upadhyay *PG-BUS, 2010Hardik Upadhyay
9HEMANG KUMAR BORICHA PG-BUS. 2010HEMANG KUMAR BORICHA
10JAYESH SUTHAR PG-BUS. 2010JAYESH SUTHAR
11Jobin Thomas Pg Bus 2010Jobin Thomas
12PERSIS ANTHONY PG-Media. 2010PERSIS ANTHONY
13Riddhima Kotwani PG-Bus 2010Riddhima Kotwani
14SUKHDEV SINGH CHANNE PGDBM 2010SUKHDEV SINGH CHANNE
15Sumeet Anand Pg Bus 2010Sumeet Anand
16Vidhi Mundra PGDBE June 2010Vidhi Mundra
17Akhil Giri PG Media 2010 Pune CampusAkhil Giri
18Divyesh Chauhan Pdbm 2010Divyesh Chauhan
19Kaushik Pg-Bus 2010Kaushik
20Kushan Mistry Pd-Bus 2010Kushan Mistry
21Sajan Shrimali Pg-Bus 2010Sajan Shrimali
22Divya Shobhawat- Pt Media - 2010Divya Shobhawat-
Sheet1
Excel 2010
Cell Formulas
RangeFormula
B2=LEFT(A2,IFERROR(SEARCH(" PD",A2,1),IFERROR(SEARCH(" PG",A2,1),IFERROR(SEARCH(" PT",A2,1),SEARCH(" ~*P",A2,1)))-1))

Hope this helps.

Regards
 
Upvote 0
Hi hardeep.kanwar,

An option with formula could be
Copy down the formula in B2:

Excel Workbook
AB
1Names
2Abhay Agarwal Pg-Bus 2010Abhay Agarwal
3Archit Vardharajan Pg Bus 2010Archit Vardharajan
4Awninder Pg-Bus 2010Awninder
5Ayush Agrawal Pg Bus 2010Ayush Agrawal
6BHARVI JOSHI PG BUS 2010BHARVI JOSHI
7Faizan Lokhandwala Pg Bus 2010Faizan Lokhandwala
8Hardik Upadhyay *PG-BUS, 2010Hardik Upadhyay
9HEMANG KUMAR BORICHA PG-BUS. 2010HEMANG KUMAR BORICHA
10JAYESH SUTHAR PG-BUS. 2010JAYESH SUTHAR
11Jobin Thomas Pg Bus 2010Jobin Thomas
12PERSIS ANTHONY PG-Media. 2010PERSIS ANTHONY
13Riddhima Kotwani PG-Bus 2010Riddhima Kotwani
14SUKHDEV SINGH CHANNE PGDBM 2010SUKHDEV SINGH CHANNE
15Sumeet Anand Pg Bus 2010Sumeet Anand
16Vidhi Mundra PGDBE June 2010Vidhi Mundra
17Akhil Giri PG Media 2010 Pune CampusAkhil Giri
18Divyesh Chauhan Pdbm 2010Divyesh Chauhan
19Kaushik Pg-Bus 2010Kaushik
20Kushan Mistry Pd-Bus 2010Kushan Mistry
21Sajan Shrimali Pg-Bus 2010Sajan Shrimali
22Divya Shobhawat- Pt Media - 2010Divya Shobhawat-
Sheet1
Excel 2010
Cell Formulas
RangeFormula
B2=LEFT(A2,IFERROR(SEARCH(" PD",A2,1),IFERROR(SEARCH(" PG",A2,1),IFERROR(SEARCH(" PT",A2,1),SEARCH(" ~*P",A2,1)))-1))

Hope this helps.

Regards

Hummmmm


That Was Great
 
Upvote 0

Forum statistics

Threads
1,224,532
Messages
6,179,388
Members
452,908
Latest member
MTDelphis

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