Get Values from a Chart

Add to Favorites

This macro will pull the values from a chart in excel and list those values on another spreadsheet. This will get the source data from charts and graphs and list this data separately. This is an espcially important feature if you only have a chart but not the source data or if the source data was damaged but you still need it separate from the chart. This macro will work for source data that has been linked to or has been lost or simply resides on an external worksheet or workbook.

IMPORTANT
Create a new sheet titled ChartData  (this is where the chart data will be placed)

To run the macro simply select the chart from which you want to pull data, either an embedded chart or a chart on its own tab, and then run the macro and the source data will be placed in the "ChartData" worksheet.

Where to install the macro:  Module

Get Source Data from a Chart

Sub GetChartValues()

'This macro will retrieve the source data from a chart in excel
'This works for charts where the source data has been lost or 
'damaged.
'Simply select the chart and run the macro - make sure to create a
'separate worksheet titled "ChartData" first though.
'
   Dim NumberOfRows As Integer
   Dim X As Object
   Counter = 2
   NumberOfRows = UBound(ActiveChart.SeriesCollection(1).Values)
   Worksheets("ChartData").Cells(1, 1) = "X Values"
   With Worksheets("ChartData")
      .Range(.Cells(2, 1), _
      .Cells(NumberOfRows + 1, 1)) = _
      Application.Transpose(ActiveChart.SeriesCollection(1).XValues)
   End With
   For Each X In ActiveChart.SeriesCollection
      Worksheets("ChartData").Cells(1, Counter) = X.Name
      With Worksheets("ChartData")
         .Range(.Cells(2, Counter), _
         .Cells(NumberOfRows + 1, Counter)) = _
         Application.Transpose(X.Values)
      End With
      Counter = Counter + 1
   Next

End Sub





Similar Content on TeachExcel
SMALL Function - Get the Lowest Values from a List in Excel
Tutorial: Return the smallest values from a list, or any of the smallest values, in Excel. This inc...
LARGE Function - Get the Highest Values from a List in Excel
Tutorial: Return the largest value from a list, or any of the top values, in Excel. This method use...
MAX and MIN Values from a Filtered List in Excel
Tutorial: How to get the MAX and MIN values from a filtered data set. This method returns the value ...
Update, Change, and Manage the Data Used in a Chart in Excel
Tutorial: In this tutorial I am going to show you how to update, change and manage the data used by ...
Changing Any Element in a Chart in Excel
Tutorial: In this tutorial I am going to go through the Layout tab in more detail and show you how t...
Macro to get Data from Another Workbook in Excel
Tutorial: Macro to get data from a workbook, closed or open, over a network or locally on your comp...



How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.


Similar Content
SMALL Function - Get the Lowest Values from a List in Excel
Tutorial: Return the smallest values from a list, or any of the smallest values, in Excel. This inc...
LARGE Function - Get the Highest Values from a List in Excel
Tutorial: Return the largest value from a list, or any of the top values, in Excel. This method use...
MAX and MIN Values from a Filtered List in Excel
Tutorial: How to get the MAX and MIN values from a filtered data set. This method returns the value ...
Excel Forum