我试图寻找片与已经创建了TextBox1.Value
的名称。然后找到一个名为“员工列表”片相同的名称和细胞超链接到表具有相同的名称。
它试图链接到“姓名”这是我在我的工作文件夹内,它甚至没有工作簿内到达。我缺少内部.Hyperlinks
参数?
Dim findEmployee As Range
Dim foundEmployee As Range
Set findEmployee = Sheets("Employee List").Range("A:A")
Set foundEmployee = findEmployee.Find(TextBox1.Value)
With Worksheets("Employee List")
.Hyperlinks.Add
Anchor:=.Range(foundEmployee.Address), _ Address:=Worksheets(TextBox1.Value).Range("A1"), _
TextToDisplay:=TextBox1.Value
End With
你可以试试这个?当您录制宏,子地址而不是使用的地址参数,而且它必须是一个字符串,而不是范围的形式。如果您的工作表名称中有空格,您需要单引号添加到字符串。
Sub x()
Dim findEmployee As Range
Dim foundEmployee As Range
Set findEmployee = Sheets("Employee List").Range("A:A")
Set foundEmployee = findEmployee.Find(TextBox1.Value)
If Not foundEmployee Is Nothing Then
With Worksheets("Employee List")
.Hyperlinks.Add Anchor:=.Range(foundEmployee.Address), _
Address:="", _
SubAddress:=Worksheets(TextBox1.Value).Name & "!A1", _
TextToDisplay:=TextBox1.Value
End With
End If
End Sub