我需要在140K行的范围内运行循环。我不断收到溢出错误。我尝试在3,000行的范围内运行脚本并且它有效。我尝试过一些东西来节约资源,但似乎没有任何效果。你可以使用最大范围吗?你们有关于在这个范围内运行循环的任何提示吗?
代码应该做的示例: 第6栏:(1,1,1,1,1,2,2,2,3,3,3,3,4,4,6,6,6,6,6,6,6,6,6 ) -----> myarray1 =(1,2,3,4,6) 第1列的值一直到行140,000
Sub transferCC()
Dim i As Integer, counter1 As Integer
Dim x As String, y As String
Dim myarray1() As String
Dim ws As Worksheet, ws1 As Worksheet, ws2 As Worksheet
Set ws = Sheets("Master")
Set ws1 = Sheets("CC List")
i = 2
counter1 = 0
x = "06331"
'save the unique CC values into myarray1
Do Until ws.Cells(i, 1) = ""
x = ws.Cells(i, 6)
y = ws.Cells(i + 1, 6) 'run-time error '6': overflow
If x <> y Then
ReDim Preserve myarray1(counter1)
myarray1(counter1) = x
Debug.Print myarray1(counter1)
counter1 = counter1 + 1
End If
i = i + 1
Loop
End Sub
答案 0 :(得分:0)
我明白了。 它与y变量无关。 它在第32767行停止,因为这将是i的值,我将其作为int而不是long来调暗。 我做了一些debug.print工作,最后在谷歌搜索32767,发现int变量只能转到32767
谢谢你们尝试每个人!