+ Reply to Thread
Results 1 to 7 of 7

find and replace - text strings

  1. #1
    Registered User
    Join Date
    08-01-2007
    Posts
    2

    find and replace - text strings

    hi,

    i have an excel file with a column of names. these are in the following format:

    MalinGR

    I need to get them into this format:

    Malin, G. R.

    Is there a find and replace function someone can point me towards so I ddon't have to do this manually as that will take ages.

    cheers

  2. #2
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Not an easy way, but if you can sort your list so that you can split the names with 2 caps and 1 cap following the names you could use this one for 2 caps following

    =LEFT(A1,LEN(A1)-2)&", "&LEFT(RIGHT(A1,2),1)&". "&RIGHT(RIGHT(A1,2),1)&"."

    and with 1 cap following

    =LEFT(A2,LEN(A2)-1)&", "&LEFT(RIGHT(A2,1),1)&". "
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  3. #3
    Forum Contributor
    Join Date
    02-23-2005
    Location
    England
    Posts
    110
    Sorry OldChippy, for butting in, but since I've spent a fair amount of time on this, maybe yabai1974 could try this macro ...

    Sub PunctuateNames()

    MinCell = 1
    MaxCell = 100

    For CellRow = MinCell To MaxCell

    For CharNo = 1 To Len(Cells(CellRow, 1))

    If CharNo = Len(Cells(CellRow, 1)) Then
    CellContents = CellContents & ". " & Mid(Cells(CellRow, 1), CharNo, 1) & "."
    Else
    If CharNo = 1 Then
    CellContents = CellContents & Mid(Cells(CellRow, 1), (CharNo), 1)
    Else
    If (Asc(Mid(Cells(CellRow, 1), CharNo)) < 96) And _
    Asc(Mid(Cells(CellRow, 1), CharNo - 1)) > 96 Then
    CellContents = CellContents & ", " & Mid(Cells(CellRow, 1), CharNo, 1)
    Else
    CellContents = CellContents & Mid(Cells(CellRow, 1), (CharNo), 1)
    End If
    End If
    End If

    Next CharNo

    Cells(CellRow, 1) = CellContents
    CellContents = ""
    Next CellRow

    End Sub


    Yabai1974 - you will need to set MinCell to the first row number for your cells and MaxCell to whatever your last row number is for the cells you want to convert.
    Last edited by PeterB; 08-01-2007 at 06:33 AM.

  4. #4
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Hi Peter, you gave me an idea there with your macro, so adjusting my formula for either senario

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-23-2005
    Location
    England
    Posts
    110
    Very elegant, I like it :-))

  6. #6
    Registered User
    Join Date
    08-01-2007
    Posts
    2
    cheers dudes. much better and quicker than anything i could have come up with.

    thanks for saving me a load of time.

  7. #7
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Glad to help, between us all we can find a number of solutions - thanks for the feedback and thanks PeterB for your macro idea

+ 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