使用长数据类型时溢出错误#6 VBA

时间:2018-05-31 15:53:31

标签: vba excel-vba integer-overflow excel

来自Python的VBA新手,因此它已经退出了差异。

Sub Average_Income()

    Dim data As Worksheet
    Dim avg As Worksheet
    Dim i As Long
    Dim Total As Long
    Dim Bottom As Long
    Dim Low As Long
    Dim Mid As Long
    Dim Mid_High As Long
    Dim High As Long
    Dim Top As Long
    Dim Number As Long


    Set data = ActiveWorkbook.Sheets("Data")
    Set avg = ActiveWorkbook.Sheets("Averages")

    Total = CLng(7)
    Bottom = CLng(8)
    Low = CLng(9)
    Mid = CLng(10)
    Mid_High = CLng(11)
    High = CLng(12)
    Top = CLng(13)

    For i = 2 To 1000
        Number = avg.Cells(i, 2)
        CLng(Number) = CLng(data.Cells(Total, 19).Value) / CLng(data.Cells(Total, 18).Value)
        Total = Total + 8
    Next i
End Sub

我觉得我已经尝试了一切!发生了什么事?

1 个答案:

答案 0 :(得分:0)

溢出是0/0分区的错误。

其他除以0得到运行时错误11:除以零。

Sub test()
    Debug.Print 0 / 0
End Sub