Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

How to disable certain code segment?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sing - 24 Nov 2007 14:26 GMT
Dear Excel Gurus,

In C, one can mask off certain code segment by using macros like;
#ifndef DISABLE_XXX
//Code to be disabled
#endif

How can I do the same thing for Excel VBA?

Thank you in advance.
SteveM - 24 Nov 2007 14:37 GMT
> Dear Excel Gurus,
>
[quoted text clipped - 6 lines]
>
> Thank you in advance.

If Condition = TRUE Then
 Exit Sub                         ' to terminate execution of the sub
and return to the calling Sub
 End                                ' to terminate and close (almost)
everything.  See the VBA help for details.
EndIF
Chip Pearson - 24 Nov 2007 15:17 GMT
You don't have the flexibility that you have with C, but you can use
conditional compilation.

#Const EXEC_THIS_CODE = False

Sub AAA()

Debug.Print 1
#If EXEC_THIS_CODE Then
   Debug.Print 2
#End If
Debug.Print 3
#If EXEC_THIS_CODE Then
   Debug.Print 4
#End If
Debug.Print 5

End Sub

Signature

Cordially,
Chip Pearson
Microsoft MVP  - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

> Dear Excel Gurus,
>
[quoted text clipped - 6 lines]
>
> Thank you in advance.
FSt1 - 24 Nov 2007 15:20 GMT
hi
see this site
http://cpearson.com/excel/vbe.htm

regards
FSt1

> Dear Excel Gurus,
>
[quoted text clipped - 6 lines]
>
> Thank you in advance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.