VBA 不连续区域怎么赋值给一个数组?
本帖最后由 zhengzunyao 于 2013-01-22 13:23:24 编辑
Sub abcd()
Dim SessionCode
Set a = Range("A50", "A100")
Set b = Range("A150", "A200")
SessionCode = Application.Transpose(Union(a, b).Value)
End Sub
Sub abcd()
Dim SessionCode1
Dim SessionCode2
SessionCode1 = Application.Transpose(Range("A50", "A100").Value)
SessionCode2 = Application.Transpose(Range("A150", "A200").Value)
m = UBound(SessionCode1)
n = UBound(SessionCode1) + UBound(SessionCode2)
ReDim Preserve SessionCode1(1 To n)
r = 1
For i = m + 1 To n
SessionCode1(i) = SessionCode2(r)
r = r + 1
Next
End Sub