Hey,
I have a couple of macro's that run when I active specific sheets. On my main sheet there are hyperlinks to various other hidden sheets. I use the below code to allow them to activate when I click the hyperlink.
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim strSheet As String
strSheet = Left(Target.SubAddress, InStr(1, Target.SubAddress, "!") - 1)
If Left(strSheet, 1) = "'" Then
strSheet = Mid(strSheet, 2, Len(strSheet) - 2)
End If
Worksheets(strSheet).Visible = xlSheetVisible
Application.EnableEvents = False
Target.Follow
Application.EnableEvents = True
End Sub
When Clicked it opens the sheet and then this Macro should run
Private Sub Worksheet_Activate()
Me.ScrollArea = "A1:Z32"
Dim PDR As Worksheet
Dim LastRow As Long, RowNo As Long
Dim Chk2 As String
Set PDR = ThisWorkbook.Worksheets("PPU Document Register")
If ActiveSheet.Cells(4, "B") <> "" Then
Chk2 = ActiveSheet.Cells(7, "B")
LastRow = PDR.Cells(Rows.Count, "A").End(xlUp).Row
For RowNo = 2 To LastRow
If PDR.Cells(RowNo, "C") = Chk2 Then
ActiveSheet.Cells(4, "M") = PDR.Cells(RowNo, "D")
End If
Next
Else
End If
End Sub
But It doesn't. Which is my problem. It used to run the code before I decided it would be neater to hide all my sheets (there are lots of them, all based on a template that has this code embedded in it)
So it must be something about having them activated using the first macro. Is there anything I could add to the code that would ensure it runs?
Thanks in advance for any help.
R
Bookmarks