1

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

反正有没有以数据的形式表示图表?

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

4

1 回答 1

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 步:运行宏

第 5 步:查看图表数据表,您在那里有自己的价值观

参考:MS Office 网站

于 2013-11-08T13:15:20.573 回答