运行时错误"6"溢出:Microsoft Excel VBA
问题描述:
我试图在Excel工作表中解决此溢出问题,但仍然无法解决.我知道我的数据确实很多(超过32767行).请查看我的代码,并帮助我提供建议.谢谢.
I tried to solve this overflow in my excel sheet and still not able to solve it. I knew that my data is really a lot (more than 32767 rows). please take a look a my code and help me advise on this. Thanks.
这是删除宏
Sub Remove()
'
' Remove Macro
'
Dim Ctr As Integer
Dim CtrS As String
Dim EOF As Boolean
Dim LstStr As String
Dim CurStr As String
Ctr = 8
LstStr = ""
Cutstr = ""
EOF = False
Do While Not EOF
CtrS = CStr(Ctr)
CurStr = Range("A" & CtrS).Value & "-" & _
Range("B" & CtrS).Value & "-" & _
Range("C" & CtrS).Value & "-" & _
Range("D" & CtrS).Value & "-" & _
Range("E" & CtrS).Value & "-" & _
Range("F" & CtrS).Value & "-" & _
Range("G" & CtrS).Value & "-" & _
Range("H" & CtrS).Value & "-" & _
Range("I" & CtrS).Value & "-" & _
Range("J" & CtrS).Value & "-" & _
Range("K" & CtrS).Value
If CurStr <> "----------" Then
If CurStr = LstStr Then
'Clear content A to N, except L
Range("A" & CtrS, "L" & CtrS).ClearContents
Range("N" & CtrS, "O" & CtrS).ClearContents
Else
LstStr = CurStr
End If
Else
EOF = True
End If
Ctr = Ctr + 1
Loop
'
End Sub
当我尝试调试时,错误指向此处:
When I tried to debug, the error point to here:
Ctr = Ctr + 1
答
将所有 Integer
声明更改为 Long
Dim Ctr As Long