Hi dear, I am still learning about hyperlinks (with shape). I have vba code in module to move from one sheet to another, like this
The code above work properly. Now, I want to add a new code so that when I click the hyperlink above (before moving to another sheet) then the second to fifth rows will be hidden
But, I still didn't get what I wanted (second to fifth lines are not hidden in Report sheet before moving to Home sheet). I still confused here how to add or putt the code so I can get what I want. Thank you.....#Sorry for my bad english
Code:
Sub HomeButton()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim rngReference As Worksheet
Dim rngDestination As Worksheet
Dim shpHyperlink As Shape
Set rngReference = wb.ActiveSheet
Set rngDestination = wb.Sheets("Home")
Set shpHyperlink = rngReference.Shapes("Rectangle 1")
rngReference.Hyperlinks.Add Anchor:=shpHyperlink, Address:="", SubAddress:="'" & rngDestination.Name & "'!B7", ScreenTip:="Back to Home"
End Sub
Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim wb As Workbook: Set wb = ThisWorkbook
Dim rngReference As Worksheet
Set rngReference = wb.Sheets("Report")
If rngReference.Rows("2:5").EntireRow.Hidden = False Then rngReference.Rows("2:5").EntireRow.Hidden = True
End Sub