+ Reply to Thread
Results 1 to 3 of 3

Splitting a Cell (no useable delimiter).....

Hybrid View

Puggy Splitting a Cell (no useable... 03-17-2005, 09:32 AM
jindon Assuming data starts from A1... 03-17-2005, 10:55 AM
Puggy You are a star sir :) Thanks... 03-17-2005, 11:31 AM
  1. #1
    Registered User
    Join Date
    03-17-2005
    Posts
    4

    Splitting a Cell (no useable delimiter).....

    Hi,

    Say I have a sheet with column A as a list of peoples names, only there is no space or comma etc, though use of capitals is correct eg:

    FredBloggs
    JasonGass
    SteveKyte

    etc etc etc.

    Is it possible to use VB, or a function to split the name into firstname in say column B and surname in Column C?

    Thinking of in some way pulling it out using the 2nd uppercase letter, but not sure how?

    Thanks
    Neil

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    Assuming data starts from A1
    Sub SplitName()
    Dim i As Integer, ii As Integer, a(), r As Range, txt
    For Each r In Range("a1", Range("a65536").End(xlUp))
        ReDim Preserve a(1 To 1): a(1) = 1: ii = 1
        For i = 2 To Len(r)
            If StrComp(Mid(r, i, 1), UCase(Mid(r, i, 1)), vbBinaryCompare) = 0 Then
                ii = ii + 1: ReDim Preserve a(1 To ii): a(ii) = i
            End If
        Next
        For i = LBound(a) To UBound(a)
            If i = UBound(a) Then
                txt = txt & "," & Mid(r, a(i), Len(r) - a(i) + 1)
            Else
                txt = txt & "," & Mid(r, a(i), a(i + 1) - a(i))
            End If
        Next
        txt = Right(txt, Len(txt) - 1): txt = Split(txt, ",")
        r.Offset(, 1).Resize(, UBound(txt) + 1).Value = txt
        Erase a: txt = ""
    Next
    End Sub
    Last edited by jindon; 03-17-2005 at 11:07 AM.

  3. #3
    Registered User
    Join Date
    03-17-2005
    Posts
    4
    You are a star sir Thanks very much

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1