“对象variables或未设置块variables”
我试图循环浏览工作簿,获取一些价值并存储在不同的工作表中。 以下是我的代码。 Keepp获得VBA对象variables或块variables未设置错误。
有人可以帮我找出哪里错了?
Sub analysis() Dim i As Integer Dim ws As Worksheet For i = 4 To 197 ws = ActiveWorkbook.Sheets(i) ws.Cells(1, 9) = ìstandardevî ws.Cells(2, 9) = Application.WorksheetFunction.StDev(Range("D3:D34")) ActiveWorkbook.Sheets(4).Cells(2, 1) = ws.Cells(2, 1) Sheets(4).Cells(2, 2) = ws.Cells(3, 8) Sheets(4).Cells(2, 3) = ws.Cells(2, 9) Next i End Sub
For / Next循环中的第一行是这样的:
ws = ActiveWorkbook.Sheets(i)
将其更改为:
Set ws = ActiveWorkbook.Sheets(i)