VBA – “错误的参数数量或无效的属性分配” – 单元格()

遵循VBA Excel上的数组教程。 正如你所看到的,几乎所有的东西都被注释掉了,我仍然得到这个错误。 如果我使用范围(“A1”,“A1”)。值= 1没有问题。 我也注意到,intelisense没有拿起'细胞('

Option Explicit Sub ArrayTest() 'Dim arrayint(1 To 5) As Integer 'Dim i As Integer 'Dim j As Integer ' For j = 1 To UBound(arrayint) ' arrayint(j) = 10 * j ' Next j ' For i = i To UBound(arrayint) Cells(1, 1).Value = 1 'arrayint(i) ' Next i End Sub 

尝试使用Application并检查是否Intellisense拿起Cells属性。
如果是这样,用这个replace你的代码:

 Application.Cells(1, 1).Value = 1 

你还没有评论该行

 Cells(1, 1).Value = 1 'arrayint(i) 

这可能是错误的原因。