EXCEL用VBA将A列不确定单元格存入数组
知道A列有10个数可以用下面存入数组,如果不知道A列有几个数怎么办?Subtest()Dima(9)AsInteger,iAsIntegerFori=1To10a(i-1...
知道A列有10个数可以用下面存入数组,如果不知道A列有几个数怎么办?
Sub test()
Dim a(9) As Integer, i As Integer
For i = 1 To 10
a(i - 1) = Range("A" & i)
Next
End Sub 展开
Sub test()
Dim a(9) As Integer, i As Integer
For i = 1 To 10
a(i - 1) = Range("A" & i)
Next
End Sub 展开
1个回答
2015-05-20 · 知道合伙人软件行家
关注
展开全部
改一改:
Sub test()
Dim a() As Integer, i As Integer,k as integer
k=1
'Range("A65536").end(xlup).row即为A列最后有数据的行号
For i = 1 To Range("A65536").end(xlup).row
ReDim Preserve a(1 to k)
a(k) = Range("A" & i).value
k=k+1
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询