我想把excel单元单元格所在列的所有数据都装入数组 arry , 不要用循环, 能不能一次性装入 ?
以下代码出错, 错误: 13 类型不匹配, 请vba 高手来看看 ?
sub 一次性转载数组()
Dim RW As Long
Dim CO As Long
Dim arry() As String
CO = ActiveCell.Column
RW = Cells(Rows.Count, CO).End(xlUp).Row
ReDim arry(1 To RW)
arry() = Range(Cells(1, CO), Cells(RW, CO)) ' 出错 类型不匹配
end sub
这样写不会出错, 但下面的比较语句会出错:
For I = 1 To RW - 1
For J = I + 1 To RW
If arry(I) = arry(J) Then '出错, 9 下标越界
GoTo finditem
End If
Next J
Next I
程序的功能是想找到重复的单元格