Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default range names in macros - syntax again

Thanks much for that info. Also, thanks to Gary.

Dean

"Rick Rothstein (MVP - VB)" wrote in
message ...
I'm not quite sure why my original one worked (I think) without
the End if. Is it only sometimes necessary?


There are two acceptable formats for If-Then statements.

If <logical expression Then <Code

and

If <logical expression Then
<Code
End If

The first form does not require an End If statement, but all your code has
to directly follow the Then keyword. Usually, this form is used when there
is a single code statement to be executed when the logical expression is
true. However, you could place multiple statements following the Then
keyword as long as they are separated from each other by a colon (but
doing so is not recommended as it makes your code much, much harder to
read). The second form is used when there are one or more code statements
to be executed when the logical expression is True. You also have to use
the second form when there will be ElseIf and/or Else tests.

Rick



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
version differences in excel 2007 - use of macros & range names difinity Excel Discussion (Misc queries) 1 May 12th 10 01:36 PM
Range names in macros - DA Dean[_8_] Excel Programming 4 October 26th 06 11:01 PM
Range names in a Excell macros karene Excel Programming 6 January 11th 06 12:55 PM
Syntax in Varying Object Names Marty Excel Programming 1 December 15th 05 06:58 PM
Names.Add - Range Syntax Issue Arturo Excel Programming 4 April 22nd 05 04:04 PM


All times are GMT +1. The time now is 09:39 AM.

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

About Us

"It's about Microsoft Excel"