运行时错误"6"溢出:Microsoft Excel VBA [英] Run-time error ' 6' overflow: Microsoft Excel VBA

查看:530
本文介绍了运行时错误"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

这篇关于运行时错误"6"溢出:Microsoft Excel VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆