+ Reply to Thread
Results 1 to 4 of 4

column of strings, column of hyperlinks - how to combine?

Hybrid View

jeff23 column of strings, column of... 08-17-2010, 08:46 PM
JBeaucaire Re: column of strings, column... 08-17-2010, 10:38 PM
jeff23 Re: column of strings, column... 08-19-2010, 04:07 PM
JBeaucaire Re: column of strings, column... 08-19-2010, 07:41 PM
  1. #1
    Registered User
    Join Date
    08-17-2010
    Location
    NYC, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    column of strings, column of hyperlinks - how to combine?

    Hey guys, I'm making my first macro and having trouble.

    In one column I have the names of reports, and in the adjacent column I have the URL hyperlinks for the reports. I'd like to have the names of the reports hyperlinked to the URLs directly so that I can just delete the messy column of web addresses.

    Any ideas for a simple script that can do this? Recording the macro doesn't work because Excel copies the links' cells, not their addresses. I have about 500 to do total in a few different columns and sheets, but the format is the same.

    The format is like this:
    A | B
    KFC | http://www.kfc.com/
    McDonalds | http://www.mcdonalds.com/
    Burger King | http://www.burgerking.com/



    Thanks!
    Jeff

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: column of strings, column of hyperlinks - how to combine?

    Like so:
    Option Explicit
    
    Sub InsertHyperlinks()
    Dim LR As Long:     LR = Range("A" & Rows.Count).End(xlUp).Row
    Dim RNG As Range:   Set RNG = Range("C1:C" & LR)
    Dim cell As Range
    
    For Each cell In RNG
        cell.Formula = "=HYPERLINK(""" & cell.Offset(, -1) & """,""" & cell.Offset(, -2) & """)"
    Next cell
    
    Range("A:B").Delete xlShiftToLeft
    Set RNG = Nothing
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-17-2010
    Location
    NYC, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: column of strings, column of hyperlinks - how to combine?

    Got it! That worked great, thanks so much JBeaucaire!!!



    Jeff

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: column of strings, column of hyperlinks - how to combine?

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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