用Excel VBA批量创建与批量删除超链接

1.批量创建超链接

a.Excel home 参考版本

Sub Drawing_Hyperlink()
Dim r As Integer, hang As Integer
r = ActiveSheet.UsedRange.Rows.Count
For hang = 2 To r
Cells(hang, "A").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=Cells(hang, "B").Value
Application.ScreenUpdating = False
Next hang
End Sub

b.改进版本

Sub Hyperlink()
Dim r As Integer, i As Integer
r = ActiveSheet.UsedRange.Rows.Count
For i = 2 To r
Cells(i,1).Hyperlinks.Add Anchor:=Cells(i,1), Address:=Cells(i, "B").Value
Application.ScreenUpdating = False
Next i
End Sub

2.批量删除超链接

Sub 批量删除超链接()
For i = 2 To 100
Cells(i,1).Hyperlinks.Delete
Next
End Sub

你可能感兴趣的:(用Excel VBA批量创建与批量删除超链接)