Hyperlink, fandt denne makro
Hej derude,Fandt denne makro på nettet som laver et link imellem de forskellige værdier som findes både i kolonne E og C.
Jeg kan så flytte rundt imellem hvilke kolonner jeg vil bruge.
Mit spørgsmål lyder om der er nogen som kan hjælpe med, at kolonne C skal være i ark 2 og dermed ikke samme ark som kolonne E, hvilket er ark1.
Se nedenstående makro:
Sub Update_Hyperlinks()
Dim LRowE, LRowC As Integer
Dim LContinue As Boolean
'Clear all hyperlinks from the active sheet
ActiveSheet.Hyperlinks.Delete
'Start at row 1 when creating hyperlinks for column E
LRowE = 1
'Create hyperlinks in column E until a blank value is encountered in column E
While Len(Range("E" & CStr(LRowE)).Value) > 0
'Start at row 1 (when searching column C values)
LRowC = 1
LContinue = True
'Stop searching column C when either a match is found, or
' a blank value in column C is found
While LContinue = True
'Found a match between column E and column C, set hyperlink and
' set boolean variable to not search any more for a match
If Range("E" & CStr(LRowE)).Value = Range("C" & CStr(LRowC)).Value Then
'Select the location for the new hyperlink
Range("E" & CStr(LRowE)).Select
'Add the hyperlink to the column C value
ActiveSheet.Hyperlinks.Add Anchor:=Selection, _
Address:="", _
SubAddress:="C" & CStr(LRowC), _
ScreenTip:="C" & CStr(LRowC)
'Found a match, so do not continue
LContinue = False
End If
'Move to next row in column C
LRowC = LRowC + 1
'A blank value is found in column C, do not continue further
If Len(Range("C" & CStr(LRowC)).Value) = 0 Then
LContinue = False
End If
Wend
'Move to next row in column E
LRowE = LRowE + 1
Wend
End Sub
