Thread: Copy hyperlinks
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Copy hyperlinks

Hi Jesper,

Am Sun, 05 May 2013 14:11:08 +0200 schrieb Jesper Kaas:

I have a sheet containing 2-300 hyperlinks to webpages in a row. The
row to the left of the row with hyperlinks contains an ID for each
link. This is a nice table, and I thought it would be a simple task to
use VLOOKUP to put the hyperlinks in to another table that uses the
same ID as in the first table with hyperlink. To give you an idea of
what I mean, please look at the example tables below:

Table 1 Table 2
ID1 Hyperlink1 ID3
ID2 Hyperlink2 ID1
ID3 Hyperlink3 ID5


modify following code to suit:

Sub CopyHyperlinks()
Dim rngC As Range
Dim c As Range
Dim LRow As Long

With Sheets("Sheet2")
LRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For Each rngC In .Range("A1:A" & LRow)
Set c = Sheets("Sheet1").Range("A1:A300") _
.Find(rngC, LookIn:=xlValues)
If Not c Is Nothing Then
c.Offset(0, 1).Copy rngC.Offset(0, 1)
End If
Next
End With
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2