ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compile Errors in Excel VBasic (https://www.excelbanter.com/excel-programming/430405-compile-errors-excel-vbasic.html)

n250jg

Compile Errors in Excel VBasic
 

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?


Mike H

Compile Errors in Excel VBasic
 

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

"n250jg" wrote:

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?


JLatham

Compile Errors in Excel VBasic
 

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.



"n250jg" wrote:

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?



All times are GMT +1. The time now is 11:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com