I'm new to programming and VBA and would like to know why this doesn't work. I get the "Next without For error". I have searched for answers, but I didn't really find any that fit this specific case. I mean, the "next" is to lines below the "for". How can it say, it would be a next without a for?
Private Sub Primerus_Click()
Number As Long, i As Long
Number = InputBox("Please enter a Number", "Math for Idiots", "Please enter your number here.")
For i = 2 To Number - 1
If Number Mod i <> 0 Then
Next i
Else: MsgBox ("This is not a prime number")
End Sub
End If
MsgBox ("This is a prime number.")
End Sub