Split Data in Two Column

g_vanita

New Member
Joined
Jul 29, 2009
Messages
4
I have Employee Names such as:

John Violet
Mary jr Dsouza
B n Chandra

I want to split it into two columns, at all places where there is a capital Character.

Such as
John Violet
Mary jr Dsouza
B n Chandra

---------------------
Regards,
~Vani~
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
This is not my personal code, will not take or give credit because I can't remember where it is due, but this will work nicely for your problem.

Assuming the names are in Column A starting at Row 1:

C1: =TRIM(LEFT(A1,MAX(((CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<91)*ROW(INDIRECT("1:"&LEN(A1)))))-1))

D1: =RIGHT(A1,LEN(A1)-MAX(((CODE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))<91)*ROW(INDIRECT("1:"&LEN(A1)))))+1)

This formula needs to be entered while holding ctrl+shift (then pressing enter - it's an array formula and you will see { } surrounding it, this step is utterly important, the formula is defunct without it). It will return the names separated by Capital letters, i.e. "John jr Smith" will be returned as | John jr | Smith |.

Hope this can help you!

Rob
 
Upvote 0
Run this bit of code on a copy of your data

It assumes the names are in column A and that columns B & C are free for the results

Code:
Sub capSplit()
    firstRow = 2
    col = "A"
    For Each cel In Range(Cells(firstRow, col), Cells(Rows.Count, col).End(xlUp)).Cells
        n = cel.Value
        i = 1
        Do
            i = i + 1
            c = Asc(Mid(n, i, 1))
        Loop Until i = Len(n) Or (c < 91 And c > 64)
        If i < Len(n) Then
            cel.Offset(, 1) = Trim(Left(n, i - 1))
            cel.Offset(, 2) = Trim(Mid(n, i, Len(n)))
        End If
    Next
End Sub

If you're not sure how to install it, hit alt+F11, choose insert -> module and paste the code in to the main space. Then alt F11 to close this window and alt+F8 to run it.

HTH
 
Upvote 0
Here's some alternative formulas
Excel Workbook
ABC
1John VioletJohnViolet
2Mary jr DsouzaMary jrDsouza
3B n ChandraB nChandra
Sheet1
Excel 2002
Cell Formulas
RangeFormula
C1=REPLACE(A1,1,LEN(B1),"")
#VALUE!
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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