循环的第一步中的变量显示溢出错误

时间:2018-10-11 21:59:59

标签: excel vba

我的代码未运行,并给我一个溢出错误。

我的代码在工作表中调用的模块中。

我收到一个错误溢出错误,因为我的“和”在循环的第一轮变得很大。

在线错误:

sum = sum + absolute

Sub FM_Report()

Dim yl As Long

Dim sum As Long

Dim absolute As Long

Dim lastrow as integer



Dim m as integer


Set wb = ActiveWorkbook

Set ws1 = wb.Worksheets("YReport")



m = 18

sum = 0

lastrow = ws1.Cells(Rows.Count, 3).End(xlUp).Row


Do While m <= lastrow

    yl = ws1.Cells(m, 16).Value

    absolute = Abs(yl)

    sum = sum + absolute

Loop

MsgBox ("sum of lost yield" & sum)

End sub

0 个答案:

没有答案