+ Reply to Thread
Results 1 to 5 of 5

Any way to use VBA to comment out / uncomment a standard module?

  1. #1
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Question Any way to use VBA to comment out / uncomment a standard module?

    Hi All

    I have this module in several workbooks

    Module Name: Has_Formula
    Please Login or Register  to view this content.
    I'm hoping there's a way to use the Workbook Open() event to un-comment all 4 lines
    And Workbook_BeforeClose() event to comment them all back out again

    Is that even possible?

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Any way to use VBA to comment out / uncomment a standard module?

    Rather than commenting out a UDF, its much easier just to not use it.

    And, yes you could use code in the Open event to remove all the REMs from commented out code. The problem is that you couldn't use that module until the changes were Saved.
    I should mention, that if you are working in a company environment, your Permissions might be set so that you can't edit vb code on the fly.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,467

    Re: Any way to use VBA to comment out / uncomment a standard module?

    Hi again,

    Take a look at the attached workbook and see if it does what you need. It uses the following code:

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M



    P. S. The above approach uses late binding, with the variables "codHas_Formula" and "vbp" being declared as type Object - you can use early binding instead if you create a reference to "Microsoft Visual Basic for Applications Extensibility 5.3"
    Attached Files Attached Files
    Last edited by Greg M; 09-04-2020 at 08:30 PM. Reason: P. S. added

  4. #4
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Any way to use VBA to comment out / uncomment a standard module?

    Ha! That is excellent! Thank you Greg
    I've saved that workbook in my bag of tricks for future

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,467

    Re: Any way to use VBA to comment out / uncomment a standard module?

    Hi again,

    Many thanks for your very prompt feedback and also for the Reputation increase - much appreciated!

    You're welcome - glad I was able to help.

    Best regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Can/should you put Worksheet code into a standard module?
    By aquixano in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-27-2017, 09:27 PM
  2. What change should I do to run this macro from standard module?
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2014, 12:34 AM
  3. What can a class do that can't be duplicated in a standard module?
    By foxguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-14-2014, 09:20 AM
  4. [SOLVED] Code locks cells when inserted in sheet module but returns error in standard module
    By yoda66 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2014, 07:39 AM
  5. VB Code to comment/uncomment code
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-25-2013, 09:06 AM
  6. [SOLVED] Use Target in standard module
    By tone640 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-23-2012, 08:18 AM
  7. Is this a standard module?
    By marianmix in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-27-2011, 03:24 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1