Click on a chart bar to drill into source data

Ronanm

Board Regular
Joined
Nov 13, 2010
Messages
107
Hi

Does anyone know if it's possible to have a chart so that when any of the series(Bars) are clicked, it will drill into the source data. Not a pivot chart, but similiar to the Pivot table where it opens a new sheet and displays the data.

Thanks

Ronan
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
What do you mean by 'drill into'? For a bar, there is only one data point, and you can see that from its tooltip.
 
Upvote 0
Hi

Thanks for tha reply

E.g. Let's say there is a chart with one os the columns showing 19 employees between the age of 30 -45.
Is there a way that the column can be clicked on which will result in the 19 employees that the column relates to showing...:confused:
And thinking about it, it would have to be a Pivot Table, and therefore a Pivot Chart to be able to drill through to the underlying data....

Should I re-ask the question in the forum stating a Pivot chart?

Regards

ronan
 
Upvote 0
No need to re-ask - I think it's clear enough now. I'll have a think.
 
Upvote 0
Got it...

Use the code below, and put in the the Chart section of VBA. Needs to be a "Pivot Chart"...

Private Sub Chart_MouseUp(ByVal Button As Long, ByVal Shift As Long, _
ByVal x As Long, ByVal y As Long)
Dim ElementID As Long
Dim Arg1 As Long
Dim Arg2 As Long


ActiveChart.GetChartElement x, y, ElementID, Arg1, Arg2

' If clicked, show detail
If ElementID = 3 Then
ActiveChart.PivotLayout.PivotTable.DataBodyRange. _
Cells(Arg2, Arg1).ShowDetail = True
ActiveSheet.Cells(2, 2).Select
ActiveWindow.FreezePanes = True
End If
ErrHandler:

If Err.Number <> 0 Then MsgBox _
"Chart_MouseUp - Error#" & Err.Number & vbCrLf & _
Err.Description, vbCritical, "Error", Err.HelpFile, Err.HelpContext
On Error Resume Next
On Error GoTo 0

End Sub


Ronan
 
Upvote 0
hi i used the code given by you its helpful but it takes multiple click and shows the data in multiple sheet, it would be great if you can help me in getting the code for drilling the data with the sheet name & only once the data should be clicked on the chart and the drill down should take place
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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