6

我正在尝试自动添加超链接并在每次添加新超链接时递增。

但是,我得到了超链接的 vba 脚本:

“无效的过程调用或参数错误”

从“linkedSheet.Hyperlinks”到“targetSheet.Name”的代码末尾出现错误

任何帮助都会很棒!

Dim targetSheet As Worksheet
Dim targetRange As Range
Dim linkedSheet As Worksheet
Dim linkRange As Range
Dim TargetRow As Long

'set variable to the sheet the hyperlink will link to
Set targetSheet = ThisWorkbook.Sheets(ActiveSheet.Name)

' specify the range on the summary sheet to link to
Set targetRange = targetSheet.Range("A1:Z100")

' set variable to sheet that will have the hyperlink
Set linkedSheet = ThisWorkbook.Sheets("Management")

For i = 6 To 1006
  Set Value = linkedSheet.Cells.Item(i, "C")
  If Len(Value) = 0 Then
  TargetRow = i
    Exit For
  End If

Next i

targetLocation = "C" & TargetRow

' specify where on that sheet we'll create the hyperlink
Set linkRange = linkedSheet.Range(targetLocation)

' create the hypperlink on the copied sheet pointing
' back to the summary sheet

  linkedSheet.Hyperlinks.Add Anchor:=linkRange, Address:="", SubAddress:= _
  "'" & targetSheet.Name & "'!" & targetRange.Address, _
  TextToDisplay:=targetSheet.Name
4

0 回答 0