我有代码在一个单元格中创建超链接。我希望它沿着F或C或E列迭代所有填充的单元格。
Sub insertVeryLongHyperlink()
Dim curCell As Range
Dim longHyperlink, TextToDisplay1 As String
Set curCell = Range("G1") ' or use any cell-reference
longHyperlink = [E1]
TextToDisplay1 = [C1]
curCell.Hyperlinks.Add Anchor:=curCell, _
Address:=longHyperlink, _
SubAddress:="", _
ScreenTip:=" - Click here to follow the hyperlink", _
TextToDisplay:=TextToDisplay1
End Sub
答案 0 :(得分:2)
这会在column G
中生成超链接。
Sub InsertVeryLongHyperlink()
Dim cl As Range
For Each cl In Range("G1:G" & Range("G1").End(xlDown).Row)
cl.Hyperlinks.Add Anchor:=cl, Address:=cl.Offset(0, -2).Text, TextToDisplay:=cl.Offset(0, -4).Text, ScreenTip:=" - Click here to follow the hyperlink"
Next cl
End Sub
cl.Offset(0, -2).Text
是E栏cl.Offset(0, -4).Text
是C列