从Excel图表/图表中获取数据

时间:2013-08-19 09:13:06

标签: excel charts excel-2010

我有一张MS excel 2010图表,显示男孩身高(y轴)与年龄(x轴)

无论如何以数据的形式表示图形?

我的问题是,给出excel中的任何图表,如果你没有制作/创建它的数据表,你可以自己从图表中创建数据表吗?

1 个答案:

答案 0 :(得分:1)

只需按照以下步骤操作:

步骤1:将以下代码复制到VBA模块中:

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

步骤2:将新工作表重命名为Chartdata

步骤3:从

中选择要获取值的图表

步骤4:运行宏

Step5:看表Chartdata,你有你的值

参考:MS OFFICE网站