我在下面的代码中遇到溢出错误:
Sub Button3_Click()
Dim inc As Integer
Dim i, j As Integer
Dim sem_new As Double
Dim aff_new As Double
Dim imu_new As Double
'Initialising Lever variables
sem_new = Sheets("Front end").Range("C6").Value
aff_new = Sheets("Front end").Range("D6").Value
imu_new = Sheets("Front end").Range("E6").Value
'Initializing increment variable
inc = 1
If Sheets("Control Sheet").Range("D5").Value = "Overall" Then
MsgBox ("Overall")
Else
For i = 8 To 408
j = 3
sem_new = sem_new + 10000
aff_new = aff_new + 10000
imu_new = imu_new - 10000
Sheets("Front end").Select
'Line where overflow occurs
Sheets("Front end").Cells(i, j).Value = ((Sheets("Front end").Range("F6").Value * ((sem_new / Sheets("Front end").Range("C6").Value) ^ Sheets("Front end").Range("H6").Value) * Sheets("Front end").Range("K6").Value) - (Sheets("Front end").Range("F6").Value * Sheets("Front end").Range("K6").Value)) / (inc * 10000) '<<<<< HERE
j = j + 1
Sheets("Front end").Cells(i, j).Value = ((Sheets("Front end").Range("F6").Value * ((aff_new / Sheets("Front end").Range("D6").Value) ^ Sheets("Front end").Range("I6").Value) * Sheets("Front end").Range("K6").Value) - (Sheets("Front end").Range("F6").Value * Sheets("Front end").Range("K6").Value)) / (inc * 10000)
j = j + 1
Sheets("Front end").Cells(i, j).Value = ((Sheets("Front end").Range("F6").Value * ((imu_new / Sheets("Front end").Range("C6").Value) ^ Sheets("Front end").Range("J6").Value) * Sheets("Front end").Range("K6").Value) - (Sheets("Front end").Range("F6").Value * Sheets("Front end").Range("K6").Value)) / (inc * 10000)
inc = inc + 1
Next i
End If
End Sub
代码运行良好3次迭代但在第四次迭代时抛出溢出错误。公式中使用的数字中没有一个超出数百万。错误出现的行在下面突出显示。任何帮助将不胜感激< / p>