Excel - How to Add Hyperlink to Plain Text

Excel 2013
Windows 7

BACKGROUND:
I have a list of names and dates all in one column that include hyperlinks. I expanded the contents of each cell to multiple columns. But, in doing so, I lost the hyperlinks.

PROBLEM:
I need a formula or Macro that takes the hyperlink from one cell in COL A and applies it to the adjacent cell in COL B, but I need to be able to tell it what SRC column and what DEST column to use; it's not always A and B.

NOTE: Only the first cell of the expanded data needs the hyperlink.

SAMPLE DATA:
Original Data - This shows the first Column that contains the original data and the adjacent Columns that have been expanded - (copy/paste this sample data to your Excel spreadsheet and then add any hyperlink by hand to first Column cells for testing)

NOTE: To retain the proper layout in Excel, you may need to paste the code first into a plain text editor such as Notepad, then copy and paste into Excel.
Last2, First2 (1079-1142)	Last2	First2	1079	1142
First3 Last3, (1098-1179)	First3 Last3		1098	1179
Last1, First1 (1986)	Last1	First1		1986
Last4, (1983)	Last4			1983

Open in new window

The result should be that the first cell in the adjacent data will contain the hyperlink from it's source cell on the left. For example, "Last2" in Cell B1 will contain the hyperlink from "Last2, First2 (1079-1142)" in Cell A1.
Jerry LOperations ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jerry LOperations ManagerAuthor Commented:
I found a solution:

'   This routine will copy ONLY the hyperlinks from the source cells
'   to the destination cells without changing the text in the destination
'   cells
'
'   SETUP:
'       Destination column in the spreadsheet must contain the text you want
'       Change Range Values in this code before running
'
Sub CopyHyperlinks()
    Dim DEST As Range           ' Specify which Column below, eg. ("B1")
    Dim SEARCH_RANGE As Range   ' Specify which rows contain the Source hyperlinks
    Dim SOURCE As Range         ' Dependent on SearchRange being initialized
   
    Set SEARCH_RANGE = Sheets(1).Range("A1:A99") ' <<< CHANGE THIS
    Set SOURCE = SEARCH_RANGE(1, 1)
    Set DEST = Sheets(1).Range("B1")                ' <<< CHANGE THIS
   
    For Each SOURCE In SEARCH_RANGE
        If SOURCE.Hyperlinks.Count > 0 Then
            DEST.Hyperlinks.Add DEST, _
                SOURCE.Hyperlinks(1).Address
        End If
        Set DEST = DEST(2, 1)
    Next SOURCE
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.