Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default If Then Statements

I have this simple code:

sub printsheet()

If Worksheets(1).Cells(1, 1) < " " Then Worksheets(1).printout

End If

end sub

I keep getting a COMPILE ERROR: End If without Block if.

My If Then syntax appears to be coorect based on the help file, what am I
doing wrong?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default If Then Statements

Figured it out. Had to move all after THEN to next line.


"Wally Steadman" wrote in message
...
I have this simple code:

sub printsheet()

If Worksheets(1).Cells(1, 1) < " " Then Worksheets(1).printout

End If

end sub

I keep getting a COMPILE ERROR: End If without Block if.

My If Then syntax appears to be coorect based on the help file, what am I
doing wrong?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default If Then Statements

or remove the End If.

You only need End If for multi-line statements, if all on one line, no need.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Wally Steadman" wrote in message
...
Figured it out. Had to move all after THEN to next line.


"Wally Steadman" wrote in message
...
I have this simple code:

sub printsheet()

If Worksheets(1).Cells(1, 1) < " " Then Worksheets(1).printout

End If

end sub

I keep getting a COMPILE ERROR: End If without Block if.

My If Then syntax appears to be coorect based on the help file, what am

I
doing wrong?






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default If Then Statements

You got it...
If Then Else can get very complex even on a single line.
I have such an example on my website.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Wally Steadman" wrote in message
...
Figured it out. Had to move all after THEN to next line.


"Wally Steadman" wrote in message
...
I have this simple code:

sub printsheet()

If Worksheets(1).Cells(1, 1) < " " Then Worksheets(1).printout

End If

end sub

I keep getting a COMPILE ERROR: End If without Block if.

My If Then syntax appears to be coorect based on the help file, what am I
doing wrong?






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
if then statements BC Excel Worksheet Functions 2 April 30th 09 11:37 PM
IF Statements (Mutliple Statements) Deezel Excel Worksheet Functions 3 October 19th 06 06:13 AM
if and or statements Debbie via OfficeKB.com Excel Discussion (Misc queries) 4 June 13th 06 02:24 PM
IF & AND statements hip Excel Worksheet Functions 5 June 7th 06 11:36 PM
If then statements David Bryant Excel Worksheet Functions 3 June 5th 06 10:41 PM


All times are GMT +1. The time now is 03:18 AM.

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"