vba在excel运行时错误‘6’溢出
代码如下:Subtest()Dimarr,brr(),x%,i%,crr,y%,k%,n%WithSheet1arr=Range("A1:C"&Range("A65536...
代码如下:
Sub test()
Dim arr, brr(), x%, i%, crr, y%, k%, n%
With Sheet1
arr = Range("A1:C" & Range("A65536").End(xlUp).Row)
ReDim brr(1 To 3, 0 To 1)
For x = 2 To UBound(arr)
crr = Split(arr(x, 3), "、")
For y = 0 To UBound(crr)
krr = Split(crr(y), "-")
j = krr(0): k = krr(UBound(krr))
For n = j To k
i = i + 1
ReDim Preserve brr(1 To 3, 0 To i)
brr(1, i) = arr(x, 1)
brr(2, i) = arr(x, 2)
brr(3, i) = n
Next n
Next y
Next x
For x = 1 To UBound(arr, 2)
brr(x, 0) = arr(1, x)
Next x
Range("F1").Resize(UBound(brr, 2) + 1, UBound(brr)) = Application.Transpose(brr)
Erase arr, brr, crr
End With
End Sub 展开
Sub test()
Dim arr, brr(), x%, i%, crr, y%, k%, n%
With Sheet1
arr = Range("A1:C" & Range("A65536").End(xlUp).Row)
ReDim brr(1 To 3, 0 To 1)
For x = 2 To UBound(arr)
crr = Split(arr(x, 3), "、")
For y = 0 To UBound(crr)
krr = Split(crr(y), "-")
j = krr(0): k = krr(UBound(krr))
For n = j To k
i = i + 1
ReDim Preserve brr(1 To 3, 0 To i)
brr(1, i) = arr(x, 1)
brr(2, i) = arr(x, 2)
brr(3, i) = n
Next n
Next y
Next x
For x = 1 To UBound(arr, 2)
brr(x, 0) = arr(1, x)
Next x
Range("F1").Resize(UBound(brr, 2) + 1, UBound(brr)) = Application.Transpose(brr)
Erase arr, brr, crr
End With
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询