Good day sir and ma’am. I am practicing VBA in excel to automate simple repetitive task to finish my projects faster. So, I try it and it is pretty simple to use. It is identical to Python programming language when it comes to its syntax. My problem is I keep encountering an error that says “Compile error” Invalid outside procedure” everytime I run my code.
Here is my VBA code:
Dim score As Integer
score = 85
If score >= 90 Then
MsgBox “Grade: A”
ElseIf score >= 80 Then
MsgBox “Grade:B”
Else
MsgBox “Grade:C”
End If
I try to run my code but it still runs in error and don’t know how to fix it. It always highlighting “85” whenever I run the code. I suspect that it is the root of error but don’t know what to do. I expected this because I am only a beginner.
Earl Nieves is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.