无效的过程调用或带有超链接

时间:2015-08-11 13:41:04

标签: vba excel-vba hyperlink invalid-argument excel

我试图在每次添加新超链接时自动添加超链接和增量。

但是,我正在使用超链接的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

0 个答案:

没有答案