I tried referring to a worksheet which has a 'comma' in its label for the 'Subadresss' property of the Hyperlink object in VBA Excel.
Any idea how to get around this, rather than replacing the comma with other symbols?
Example: My worksheet's name is : 1,1a
Here is the code for the hyperlink:
Worksheets("Worksheet1")
.Hyperlinks.Add Anchor:=.Range("c46"), _
Address:="", _
SubAddress:="1,1a!A1"
On clicking on such a hyperlink, I will get a 'Reference is not valid' error.
工作表名称需要在引号内:
SubAddress:="'1,1a'!A1"
Don't know if you're still looking for an answer to this, but I did some testing, and assuming the workbook containing sheet 1,1a is named 'Workbook1.xlsx', this code should accomplish this:
With Worksheets("Worksheet1")
.Hyperlinks.Add Anchor:=.Range("c46"), _
Address:="Workbook1.xlsx", _
SubAddress:="'1,1a'!A1"
End With
These pieces of knowledge seemed significant:
See the HYPERLINK function documentation for more information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.