Compile Errors in Excel VBasic

N

n250jg

I've been running a macro to sort data in Excel but just recently I'm getting
Compile errors such as "loop without do" and "next without for" and "block if
without end if", but obviously that is not the case. This was running fine
before. Any suggestions?
 
M

Mike H

Hi,

It wouldn't have run previously with this error because this type of error
stops the code compiling so maybe it got accidentally altered. Post your code
and someone will help.

Mike
 
J

JLatham

As Mike H said, wouldn't have run earlier if any of those were true then.

Are all of these errors coming from a single routine or from several
different sections of the code? Typically if you have a bunch of nested
loops and ifs, the debugger reports the error as being in the outermost block
even though that may not be true. That is, if you have
Sub testerrors()
Dim X As Integer
For X = 1 To 10
If X = 4 Then
MsgBox "X is 4"
Next
End Sub

will give you a "Next Without For" error indication even though it is really
the End If that is the missing element.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top