請看下列程式碼 , 可以將A1儲存格的連結 換到A2儲存格
Sub 交換律()
Range("A1").Select
Selection.Cut Destination:=Range("A3")
Range("A2:A3").Select
Selection.Cut Destination:=Range("A1:A2")
Range("A1").Select
End Sub
方法利用A3儲存格進行搬移而已
也可以用下列程式
Sub 交換律()
Dim myhyps As Hyperlinks
Dim myhyp As Hyperlink
myx1 = Range("a1").Value
myx2 = Range("a2").Value
Set myhyps = Range("a1").Hyperlinks
Set myhyp = myhyps(1)
x1 = myhyp.Address
Set myhyps = Range("a2").Hyperlinks
Set myhyp = myhyps(1)
x2 = myhyp.Address
With Worksheets(1)
.Hyperlinks.Add Anchor:=.Range("a1"), _
Address:=x2, _
TextToDisplay:=myx2
.Hyperlinks.Add Anchor:=.Range("a2"), _
Address:=x1, _
TextToDisplay:=myx1
End With
End Sub