I'm having trouble with vba code from a course I'm taking. I'm getting an overflow error when I try to run it, and I'm not sure what the issue is.
edit: I used Excel on a Windows machine and it worked fine, my mac is giving me this error when the code is identical.
This is the code:
Option Explicit
Sub Prequiz7()
Dim i As Double, j As Double, pig As Double, k As Double
pig = 10: j = 16: i = 0
For i = 1 To 2 Step 0.5
If (i >= 1.5) Then
pig = pig + i
End If
For k = 1 To 2
MsgBox pig + k
Next k
Next i
MsgBox pig & " " & i & " " & j
Do While (j > 10)
If (j < 12) Then
Exit Do
End If
j = j - 2
Loop
MsgBox j
End Sub
This is the error
"Run time error: '6'
Overflow"
If I debug it highlights the Next k line
Does anyone know why this error is happening, it seems like declaring the variable for k and pig As Double should prevent the Overflow error.
If I take away Option Explicit and the Dim line, it will show 2 message box's instead of one, and the error happens at the Next i line