PDA

View Full Version : How to use ' to ignore large section of codes



zcy198236
11-13-2009, 10:21 AM
Hi, I know if I put ' in front of a line of code, vba will ignore what I write after '. My question is how to ignore large section of the code without putting ' in front every line.


Many thanks

stanleydgrom
11-13-2009, 11:45 AM
zcy198236,

Welcome to the VBAExpress forum.

Try:




Goto NextArea

'skip all these lines of code witout entering ' at the start of each line


NextArea:

'start executing code here





Have a great day,
Stan

Bob Phillips
11-13-2009, 12:16 PM
In the VBIDE there is a toolbar that is not visible by default called Edit. This has a button to comment a whole block, select multiple rows and hit this button and they all get commented.

Paul_Hossler
11-13-2009, 01:20 PM
If you might want to execute the code sometime and not others, you can use Conditional Compilers Directives to enable/disable as needed


Option Explicit
#Const Debugging = False
Sub Demo()
MsgBox "A"
MsgBox "B"

#If Debugging Then
MsgBox "C"
MsgBox "D"
MsgBox "E"
MsgBox "F"
#End If

MsgBox "G"
MsgBox "H"
End Sub


Paul

zcy198236
11-13-2009, 02:12 PM
Thank you for all the replies.


Best regards