+ Reply to Thread
Results 1 to 4 of 4

Multiple replacements from one column to another

Hybrid View

  1. #1
    Registered User
    Join Date
    06-06-2011
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    1

    Multiple replacements from one column to another

    Hi, I am new to excel and I am really worried since I can’t find a solution to a problem:
    I’ve got 2 columns:

    Column 1
    http://www.whois.domaintools.com/
    http://www.host-file.net/default.asp?s=
    http://www.aboutus.org/
    http://www.quantcast.com/

    Column 2:
    http://www.jumptags.com/thomasjorgy/
    http://www.kaboodle.com/tag/proxies
    http://marketplace.sitepoint.com/listings/73210
    http://www.meernieuws.be/article.php?id=6234879
    I need to replace column 2 with column 1, BUT I only need to replace the text “http://www.” from column 2 with the data of column 1, for e.g. The result from doing this replacement from the first cells from both columns would be:
    “http://www.whois.domaintools.com/jumptags.com/thomasjorgy/”
    (we have replaced the “http://www.” from column 2 and replaced it with the first cell of column 1).

    But the problem is that EACH cell on column 2 needs to be replaced with the entire column 1.

    So on column 2 “http://www.jumptags.com/thomasjorgy/” has to be replaced with the entire column 1 and as a result we would get:
    http://www.whois.domaintools.com/jumptags.com/thomasjorgy/
    http://www.host-file.net/default.asp?s=jumptags.com/thomasjorgy/
    http://www.aboutus.org/jumptags.com/thomasjorgy/
    http://www.quantcast.com/jumptags.com/thomasjorgy/

    And on the second cell of column 2 “http://www.kaboodle.com/tag/proxies” has to be replaced with the entire column 1 and as a result we would get:
    http://www.whois.domaintools.com/kaboodle.com/tag/proxies
    http://www.host-file.net/default.asp?s=kaboodle.com/tag/proxies
    http://www.aboutus.org/kaboodle.com/tag/proxies
    http://www.quantcast.com/kaboodle.com/tag/proxies
    And so on.

    Is there a way to do this fast in excel? I have got around 10,000 cells with text on column 2 and 100 cells with text on column 1 and I can't possibly do this by hand.
    I really need this fast, it’s urgent. Please help me.
    Last edited by frndelavega; 06-06-2011 at 11:13 AM.

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Help me please, otherwise I will get fired- Replacing excel columns

    Hi,

    Welcome to the Forum. When you have modified your title as directed by the moderator then we can help you. I already have a solution but I can' t post it until you abide by the moderator's requests.

    abousetta

  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Multiple replacements from one column to another

    Hello,

    Thank you for modifying your title. You can try something like this:

    S' Cl1 represents Column 1 and Cl2 represents Column 2
    Dim Cl1 As Long, Cl2 As Long
    
    ' This will set the number of rows used in Column A and Column B and then loop through them in sequence
    For Cl1 = 1 To Range("A" & Rows.Count).End(xlUp).Row
        
        For Cl2 = 1 To Range("B" & Rows.Count).End(xlUp).Row
        
          ' This is the work done in Column C
            Range("C" & Range("C" & Rows.Count).End(xlUp).Row + 1) _
                = Range("A" & Cl2).Value & Right(Range("B" & Cl1).Value, Len(Range("B" & Cl1)) - 11)
    
        Next Cl2
        
    Next Cl1
    
    ' Erase the first Cell in Column C since it is empty. This will allign the rows correctly.
      Range("C1").Delete Shift:=xlUp
    What this does is create the list that you are looking for in Column C. Then you can simply copy/ paste it wherever you want. If you want any modifications, please post back.


    Here is the result that I got with the vba code:

    http://www.whois.domaintools.com/jumptags.com/thomasjorgy/
    http://www.host-file.net/default.asp?s=jumptags.com/thomasjorgy/
    http://www.aboutus.org/jumptags.com/thomasjorgy/
    http://www.quantcast.com/jumptags.com/thomasjorgy/
    http://www.whois.domaintools.com/kaboodle.com/tag/proxies
    http://www.host-file.net/default.asp?s=kaboodle.com/tag/proxies
    http://www.aboutus.org/kaboodle.com/tag/proxies
    http://www.quantcast.com/kaboodle.com/tag/proxies
    http://www.whois.domaintools.com/etplace.sitepoint.com/listings/73210
    http://www.host-file.net/default.asp?s=etplace.sitepoint.com/listings/73210
    http://www.aboutus.org/etplace.sitepoint.com/listings/73210
    http://www.quantcast.com/etplace.sitepoint.com/listings/73210
    http://www.whois.domaintools.com/meernieuws.be/article.php?id=6234879
    http://www.host-file.net/default.asp?s=meernieuws.be/article.php?id=6234879
    http://www.aboutus.org/meernieuws.be/article.php?id=6234879
    http://www.quantcast.com/meernieuws.be/article.php?id=6234879
    Good luck.

    abousetta
    Attached Files Attached Files
    Last edited by abousetta; 06-06-2011 at 09:19 PM. Reason: Corrected code

  4. #4
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Multiple replacements from one column to another

    Hi,

    I just updated the code and workbook because I realized that I did not understand the request exactly the first time around. If this is not what you are looking for or need a modification, please post back.

    Good luck.

    abousetta

+ 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