Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA ERROR
I am running an 16 if functions similar to this below:
If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True End If When I try to run it I get an error saying "Block If without End if" My very last function ends with: End If End Sub But if I take the end sub out I get an error that reads" Expected end Sub" ??? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA ERROR
ALL of your If-Then blocks (the one's where nothing follows the Then on the
same line) MUST have a matching End If statement... every one of them. And, if the If-Then blocks are nested, the End If statements must be located correctly. If you post that part of your code dealing just with the 16 If-Then calls (and if it isn't too long to follow), I'm sure someone here will restructure it for you. Rick "Hamed parhizkar" wrote in message ... I am running an 16 if functions similar to this below: If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True End If When I try to run it I get an error saying "Block If without End if" My very last function ends with: End If End Sub But if I take the end sub out I get an error that reads" Expected end Sub" ??? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA ERROR
When I try to run it I get an error saying "Block If without End if"
That means that you're missing an End If somewhere. My very last function ends with: End If End Sub But if I take the end sub out I get an error that reads" Expected end Sub" When VBA compiles it looks at the SUB, END SUB combos take make sure that it finds one before checking the IF, END IF. When you remove the END SUB, it causes VBA to throw that error. Cheers, Jason Lepack |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
run time error 1004 general odbc error excel 2003 vba | Excel Programming | |||
Error Handling - On Error GoTo doesn't trap error successfully | Excel Programming | |||
Form Err.Raise error not trapped by entry procedure error handler | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming | |||
Automation Error, Unknown Error. Error value - 440 | Excel Programming |