+ Reply to Thread
Results 1 to 11 of 11

VB Code to comment/uncomment code

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to comment/uncomment code

    Hello:

    Please refer to the code below.
    As you can see
    ' Sheets("1").Select is commented

    I want a VB Macro to uncomment that line and comment out line Sheets("2").Select

    Please let know if any questions.

    Riz


    Please Login or Register  to view this content.
    Last edited by rizmomin; 03-24-2013 at 02:03 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VB Code to comment/uncomment code

    Perhaps this link would help.

    Extensibility: code in VBA that reads or modifies other VBA projects, modules, or procedures

  3. #3
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to comment/uncomment code

    Hi AlphaFrog:

    I could not find much help at that site.

    Please help..

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VB Code to comment/uncomment code

    Riz

    That site shows you how to use code to write code, which is what you are trying to do as far as I can see.

    I've not looked at it recently but as far as I can remember it covers most aspects of doing that.
    If posting code please use code tags, see here.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VB Code to comment/uncomment code

    What are you trying to do (big picture) and why do you want to comment\uncomment code with other code?

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to comment/uncomment code

    Hi AlphaFrog:

    When I open the excel file, it automatically goes to SheetX1 and lots of other sheets are unhidden.

    However, I want to share this file with some other user and before i give it to them i like to change the macro to auto open SheetX2 and hide some sheets.

    Please have a look at the code below:

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: VB Code to comment/uncomment code

    Hello Riz,

    Try something with this code.
    Please Login or Register  to view this content.
    Last edited by HSV; 03-24-2013 at 06:24 PM.
    Kind regards, Harry.

  8. #8
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to comment/uncomment code

    Hi Harry:

    In module1, I have lots of Macro code.
    How would I choose Sub Open()

    Thanks

    Riz

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VB Code to comment/uncomment code

    Self-modifying code was regarded with disdain the day it was invented, and that hasn't changed.

    If Environ("username") = "riz" then
    ' do this
    Else
    ' do that
    Endif
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to comment/uncomment code

    Hi shg:
    I think this is one option i will try.
    Thanks a lot for great tip.

    Riz

  11. #11
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to comment/uncomment code

    Hi shg:
    I think this is one option i will try.
    Thanks a lot for great tip.

    Riz

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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