#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Form Err.Raise error not trapped by entry procedure error handler [email protected] Excel Programming 1 February 8th 06 10:19 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


All times are GMT +1. The time now is 09:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"