PingPongMan
New Member
- Joined
- Nov 27, 2018
- Messages
- 1
Hey guys,
as part of a larger macro, I want to insert a code that creates a link to the latest sheet of the workbook and name it according to the text in the selcted cell.
This was asked in a simliar way before (https://www.mrexcel.com/forum/excel...ng-hyperlink-last-worksheet-workbook-vba.html), but when I inserted the exact same code, the link saying "hello" was created but clicking on it lead to an error saying the reference is invalid, which is the same error Im getting with the code below:
If anybody could help me with that, thank you very much in advance!
Best regards!
as part of a larger macro, I want to insert a code that creates a link to the latest sheet of the workbook and name it according to the text in the selcted cell.
This was asked in a simliar way before (https://www.mrexcel.com/forum/excel...ng-hyperlink-last-worksheet-workbook-vba.html), but when I inserted the exact same code, the link saying "hello" was created but clicking on it lead to an error saying the reference is invalid, which is the same error Im getting with the code below:
Code:
Sub CreateHyperlinkToLastSheet()
Range("D43").Select
Dim x As Integer
x = ThisWorkbook.Sheets.Count
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"x!A1", TextToDisplay:=TextToDisplay:=Range("D43").Value
End Sub
If anybody could help me with that, thank you very much in advance!
Best regards!