How to comment/uncomment vba code using VBA Code

Vishal Bharakhada
Vishal Bharakhada used Ask the Experts™
on
Hi ,
Problem statement : We are having a UDF in our EXCEL 2016 and a subroutine. UDF at present commented. After execution of few lines in subroutine we want to uncomment UDF using vba code only.

Please suggest whether it is possible using code, if it is then would request to provide code for the same.

Regards,
Vishal G. B.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Older than dirt
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Uncommenting code using VBA is not possible. You could however create a global Boolean variable in VBA called, say, gbSkip which you would initially set to True, and then in the UDF add this as the first line:
If gbSkip = True then Exit Function
When you want to "uncomment" the UDF, set gbSkip to False.
mbizupNerd
Most Valuable Expert 2012
Top Expert 2013

Commented:
Why not simply use conditional code such as If-Then and/or Exit Sub statements to call the UDF only when needed?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial