inkserious
Technical User
- Jul 26, 2006
- 67
I have a workbook that contains six or seven sheets. I have a Pivot Chart on Sheet5 whose source data comes from a Pivot Table on Sheet2. I've created a button on the Pivot Chart sheet that when clicked will hide the sheet. Once clicked, I would like the Worksheet that the Pivot Chart source data is coming from to be selected.
So if the button on Sheet5 is clicked, Sheet2 will be selected. I have an example below but this requires me to create a separate Sub for each chart as it hard codes the sheet that needs to be selected. How can I extract the Pivot Chart's source data Sheet name and pass it to a variable and then use that to select the sheet?
Any help would be greatly appreciated.
-ep
So if the button on Sheet5 is clicked, Sheet2 will be selected. I have an example below but this requires me to create a separate Sub for each chart as it hard codes the sheet that needs to be selected. How can I extract the Pivot Chart's source data Sheet name and pass it to a variable and then use that to select the sheet?
Any help would be greatly appreciated.
-ep
Code:
Sub HideChart()
Dim ws As Worksheet
Set ws = Sheets("Sheet2")
ActiveSheet.Visible = xlSheetHidden
ws.Select
End Sub