+ Reply to Thread
Results 1 to 14 of 14

Manipulating Text strings

  1. #1
    Registered User
    Join Date
    11-19-2009
    Location
    CA
    MS-Off Ver
    Excel 2007
    Posts
    62

    Manipulating Text strings

    Hi Guys,

    Can you help me with my little problem.
    I have a column filled with names per row. I wanted to standardize it by using the following format.
    The comma after the last name is always an indicator to me that it is the last name.

    <First Name> <Middle Initial(if any)> <Last Name>

    My actual records contains the following:

    BIMBO EPPING - OK
    AHMAD SADICK - OK
    Salana, Laura R - need to be arranged to > Laura R Salana
    Cantos, Rhoda Grace J - need to be arranged to > Rhoda Grace J Cantos


    thanks guys.
    Last edited by xmoore; 01-15-2010 at 07:14 AM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Manipulating Text strings

    See if this might work

    =RIGHT(A1,FIND(",",A1))& " " &LEFT(A1,FIND(",",A1)-1)

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Manipulating Text strings

    Hi,

    with your names in column A

    =IF(ISERROR(FIND(",",A1)),A1,MID(A1,FIND(",",A1)+2,99)&" "&LEFT(A1,FIND(",",A1)-1))

    copy down

    hth

  4. #4
    Registered User
    Join Date
    11-19-2009
    Location
    CA
    MS-Off Ver
    Excel 2007
    Posts
    62

    Thumbs up Re: Manipulating Text strings

    Thanks Rocky1, Teylyn for the assistance.

    I adopted Teylyn's formula since it too includes the error handling for rows without ","

    thanks guys.. appreciate it.

  5. #5
    Registered User
    Join Date
    11-19-2009
    Location
    CA
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Manipulating Text strings

    I have a follow up question if I may.

    How do I pass the formula to VBA code so as not to insert the formulas per cell.
    Inserting the formula to each cell adds to the file size.

    I have the following code initially created

    Please Login or Register  to view this content.
    Hope to hear from you guys soon... Im having sleepless nights over this report.

    thanks.
    Last edited by DonkeyOte; 01-13-2010 at 05:01 AM. Reason: Tags added

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Manipulating Text strings

    xmoore, you've been around long enough now to know...

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  7. #7
    Registered User
    Join Date
    01-12-2010
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Manipulating Text strings

    If you're doing it in VBA you don't have to make it so complicated:

    Please Login or Register  to view this content.
    I assume you're happy to run the macro whenever the data is updated. If you just want to update the data in place, remove the Offset(0,1). code

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Manipulating Text strings

    xmoore, given the above poster went to the trouble of putting together a detailed response I've modified your prior post...

    at this point I noted you seemingly tried to add Tags but it went wrong...

    To add CODE tags

    [*CODE*]

    your VBA

    [/*CODE*]

    without the asterisks of course...

    David Huang - welcome to the board - going forward please refrain from posting on threads where OP has been requested to comply with Forum Rules but has yet to do so...

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Manipulating Text strings

    You could perhaps avoid Iteration altogether and use Evaluate...

    Your ranges aren't very clear in truth

    Please Login or Register  to view this content.
    that said the above is not for the feint hearted and it would be just as easy to write the formulae en masse and overwrite with results thereafter - still avoiding iteration, eg:

    Please Login or Register  to view this content.
    adjust ranges to suit.

  10. #10
    Registered User
    Join Date
    11-19-2009
    Location
    CA
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Manipulating Text strings

    Hi DonkeyOte,
    I tried your code and worked a lot faster. I'm running it on an actual 100K line items.
    Question: How do I make the output in upper case? Tried to insert the "UPPER" function but returned with an error.

    thanks,
    xmoore

  11. #11
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Manipulating Text strings

    You don't specify which option you went for...

    Using Evaluate:

    Please Login or Register  to view this content.
    Using Temp Formulae:

    Please Login or Register  to view this content.
    ie in both cases it's simply a case of encasing the True part of the initial IF within an UPPER function.

  12. #12
    Registered User
    Join Date
    11-19-2009
    Location
    CA
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Manipulating Text strings

    I used the Evaluate.
    I'm also trying to look for more information about "Evaluate" function?
    Seems to be used more often in string manipulation.

    thanks again.

  13. #13
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Manipulating Text strings

    A general chit chat about it can be found at: http://www.ozgrid.com/forum/showthread.php?t=52372

    It's most commonly seen to conduct SUMPRODUCT calcs in VBA

    It's also a good way of conducting other Array formulae in VBA/memory given the fact it processes formulae as an Array by default (like say Conditional Formatting rules etc...) - eg:

    Please Login or Register  to view this content.
    Using it to avoid iteration etc is not a technique I dreamt up unfortunately rather it is something I picked up from Bill Jelen's book "Excel Gurus Gone Wild".

  14. #14
    Registered User
    Join Date
    11-19-2009
    Location
    CA
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Manipulating Text strings

    Appreciate the assistance DonkeyOte.

    best regards,
    xmoore

+ 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