VBA advanced: internal hyperlink to work in pivot table

TOTAL

New Member
Joined
May 31, 2017
Messages
8
Hi

I know it is possible to do: see the "test 2" (https://www.dropbox.com/s/ljfmphkp4uxu3is/test2.xlsm?dl=0) file. As you click on the pivot table cells, you get directed to the relevant tabs.

Have tried to achieve this in my file, but for some reason, the same trick does not appear to work - see "zero test 2" file (https://www.dropbox.com/s/zyp8e2g0sqygweb/zero test 2.xlsm?dl=0).

The vba code involved is as follows:
Code:
Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)




    Dim pvtTable As PivotTable
    Dim shtTemp As Worksheet
    
    If Target.Cells.Count = 1 Then
        For Each pvtTable In Target.Parent.PivotTables
            If Not Intersect(pvtTable.RowRange, Target) Is Nothing Then
                On Error Resume Next
                Set shtTemp = Worksheets(Trim(Target.Value))
                On Error GoTo 0
                If Not shtTemp Is Nothing Then
                    Application.Goto shtTemp.Range("A1")
                End If
            End If
        Next
    End If
End Sub

Please help.
Thanks
T
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,224,828
Messages
6,181,206
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top