【发布时间】:2017-08-03 15:48:32
【问题描述】:
我是 Excel 新手,所以我希望这是有道理的。下面的代码显示了当单击用户表单上的按钮时,在特定工作簿(与当前工作簿不同)上创建的新工作表。不过,我在单独工作簿上创建的工作表的超链接似乎已损坏。我究竟做错了什么?有什么帮助,谢谢!
Dim LastRow As Long, ws As Worksheet
Set ws = Sheets("Employee Information")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
If Me.cbStores.Value = "Northern" Then
Dim newWB As Workbook
Dim thisWB As Workbook
Set thisWB = ThisWorkbook
Set newWB = GetOrCreateWB("EmployeeTemplates", "C:\Users\...\Folder") '<--| Opening EmployeeTemplates wb
thisWB.Sheets("Template").Copy after:=newWB.Sheets(1)
With ActiveSheet '<--| the just pasted worksheet becomes the active one
.Name = AddEmployeeUF.txtFirstname.Text + AddEmployeeUF.txtMiddleinitial.Text + AddEmployeeUF.txtLastname.Text + "Template" '<--| Name it
ws.Hyperlinks.Add Anchor:=ws.Range("F" & LastRow), Address:="", SubAddress:=.Name & "!A1", TextToDisplay:="View" '<--| hyperlink to new sheet
End With
End If
【问题讨论】:
标签: vba excel hyperlink excel-2010