1
votes

I have an MS excel 2010 chart which shows the boys height (y-axis) vs age (x-axis)

Is there anyway to represent the graph in the form of a data?

My questions is, given any chart in excel and if you dont have the data table from which it was made/created, can you yourself create the data table from the chart that is available with you?

1

1 Answers

1
votes

Just follow the following steps:

Step 1: Copy following code into a VBA module:

Sub GetChartValues()  
   Dim NumberOfRows As Integer  
   Dim X As Object  
   Dim Counter as Integer  
   Counter = 2  

   ' Calculate the number of rows of data.  
   NumberOfRows = UBound(ActiveChart.SeriesCollection(1).Values)  

   Worksheets("ChartData").Cells(1, 1) = "X Values"  

   ' Write x-axis values to worksheet.  
   With Worksheets("ChartData")  
      .Range(.Cells(2, 1), _  
      .Cells(NumberOfRows + 1, 1)) = _  
      Application.Transpose(ActiveChart.SeriesCollection(1).XValues)  
   End With  

   ' Loop through all series in the chart and write their values to  
   ' the worksheet.  
   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

Step 2: Rename a new worksheet as Chartdata

Step 3: Select the chart you want to get your values from

Step 4: Run the macro

Step 5: See the sheet Chartdata, you have your values there

REFERENCE: MS OFFICE WEBSITE