Sửa Sổ Làm Việc Bị Lỗi - Microsoft Support

Sử dụng macro để trích xuất dữ liệu từ sổ làm việc bị hỏng     Nếu biểu đồ được nối kết với sổ làm việc bị hỏng, bạn có thể sử dụng macro để trích xuất dữ liệu nguồn của biểu đồ.

Để sử dụng macro, hãy làm như sau:

  1. Nhập mã macro sau đây vào trang tính mô-đun:

    Sub GetChartValues() Dim NumberOfRows As Integer Dim X As Object 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. Chèn một trang tính mới vào sổ làm việc của bạn và đổi tên nó thành Dữ liệu biểu đồ.

  3. Chọn biểu đồ mà bạn muốn trích xuất các giá trị dữ liệu cơ sở từ đó.

  4. Lưu ý: Biểu đồ có thể được nhúng vào một trang tính hoặc trên một trang tính biểu đồ riêng biệt.

  5. Chạy macro GetChartValues.

  6. Dữ liệu từ biểu đồ sẽ được đặt trên trang tính ChartData.

Từ khóa » Excel Bị Lỗi Không Sử Dụng được