0

运行以下代码时出现对象定义错误。请帮我调试代码。

For i = 5 To 11
Cells(i, G).Value = Application.WorksheetFunction.CountIf(Workbooks(1).Sheets(1).Range("H:H"), Cells(i, F).Value) + Application.WorksheetFunction.CountIf(Workbooks(1).Sheets(2).Range("H:H"), Cells(i, F).Value)
Next i
4

1 回答 1

1

您需要在列周围加上引号,否则 F 和 G 是变量。

For i = 5 To 11
Cells(i, "G").Value = Application.WorksheetFunction.CountIf(Workbooks(1).Sheets(1).Range("H:H"), Cells(i, "F").Value) + Application.WorksheetFunction.CountIf(Workbooks(1).Sheets(2).Range("H:H"), Cells(i, "F").Value)
Next i
于 2013-10-30T17:30:24.190 回答