Sub ScreenTip()
Dim hl As Hyperlink
For Each hl In ActiveSheet.Hyperlinks
hl.ScreenTip = CStr(hl.Range.Value)
Next
End Sub
我有这个代码,但它只在您当前使用的工作表上运行。我希望它能够覆盖整个工作簿。我该如何改变呢?
答案 0 :(得分:3)
更改您的For Each
并添加新变量
Sub ScreenTip()
Dim hl As Hyperlink
Dim ws as WorkSheet
For Each ws in ActiveWorkbook.Worksheets
For Each hl In ws.Hyperlinks
hl.ScreenTip = CStr(hl.Range.Value)
Next hl
Next ws
End Sub
答案 1 :(得分:2)
Sub ScreenTip()
Dim hl As Hyperlink
dim sh as worksheet
dim bk as workbook
set bk = whateverbook
for each sh in bk.sheets
For Each hl In sh.Hyperlinks
hl.ScreenTip = CStr(hl.Range.Value)
Next hl
next sh
End Sub