+ Reply to Thread
Results 1 to 2 of 2

Thread: Macro For Cleansing

  1. #1
    Registered User
    Join Date
    12-30-2011
    Location
    London, Ont
    MS-Off Ver
    Excel 2007
    Posts
    61

    Macro For Cleansing

    The situation is: I have a about 15000 lines of data that needs to be cleansed. I need to change the Item description from e.g
    Uncleansed = OFFSET TIB TRAY NEUTRAL ADAPTOR
    Cleansed = ADAPTOR OFFSET TIB TRAY NEUTRAL
    is there a way I can do this automatically? with a macro?
    thanks

  2. #2
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,352

    Re: Macro For Cleansing

    bigdee008@yahoo.com,

    Welcome to the forum!
    If all you need is to put the last word as the first word, either of these should work for you:

    Formula solution:
    =TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99))&" "&SUBSTITUTE(A1," "&TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99)),"")


    Macro solution:
    Sub tgr()
        
        With Range("A1", Cells(Rows.Count, "A").End(xlUp))
            .Offset(, 1).Formula = "=TRIM(RIGHT(SUBSTITUTE(A" & .Row & ","" "",REPT("" "",99)),99))&"" ""&SUBSTITUTE(A" & .Row & ","" ""&TRIM(RIGHT(SUBSTITUTE(A1,"" "",REPT("" "",99)),99)),"""")"
            .Offset(, 1).Value = .Offset(, 1).Value
        End With
        
    End Sub
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0