Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1223
  • Last Modified:

On/Off switch for VBA code

Simple question for everyone...

In C++, I used to use #define to switch code on and off as follows:

#define DUMMY

#ifdef DUMMY
some code here...
#endif

If I commented out "#define DUMMY", the compiler would ignore all the code between #ifdef and #endif.

Is there anything in VBA that I can use to switch code blocks on and off like this?

Dan
0
ltdanp22
Asked:
ltdanp22
  • 2
1 Solution
 
nffvrxqgrcfqvvcCommented:

#Const DUMMY = 1

#If DUMMY Then
  '// some code
#End If

Open in new window

0
 
ltdanp22Author Commented:
Thanks! What does the # symbol do?
0
 
nffvrxqgrcfqvvcCommented:
It's a conditional compilation prefix statement used in VB which should work in VBA. #Define  in VB = Const but for conditional compilation use #Const.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now