我在 A 列中有 15 个名称。在尝试 ReDim 并填充已声明的数组并将元素(名称)提取到 E 列时,以下代码让我打嗝,说它是运行时错误 1004(应用程序定义的或对象定义错误)。
Dim f() as string
Private Sub CommandButton1_Click()
Finalrow = Cells(Rows.Count, 1).End(xlUp).Row
ReDim Preserve f(Finalrow - 1)
For i = 0 To Finalrow - 1
f(i) = Sheet1.Cells(i, 1) ''''This line causes the glitch (error 1004)
Next
For i = 0 To Finalrow - 1
Sheet1.Cells(i, 5) = f(i)
Next
End Sub
循环变量i从 0 开始;这会杀死该Cells()
功能。
(可能还有其他错误)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句