+ Reply to Thread
Results 1 to 9 of 9

Macro that can change a line of code in another macro

  1. #1
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Macro that can change a line of code in another macro

    I have a macro that currently has a line of code that is ignored by using " ' " in the front.

    Please Login or Register  to view this content.
    I would like to have a macro that would remove the apostrophe or put it back by clicking a macro... rather than me doing it manually.

    also I would like that when you run the macro it would add the text "activated" in cell (Z:275)
    and vise versa when run again and it adds the apostrophe back it would change the text to "deactivated"

    How would I accomplish this

    thanks
    Last edited by bdouglas1011; 12-16-2018 at 03:15 PM. Reason: made addition

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro that can change a line of code in another macro

    Do you need to clear the contents of this range or not ..?
    If yes so uncomment the line and keep it .. and if not so keep it as it is
    Why do you need such action?
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Macro that can change a line of code in another macro

    I would perhaps come at this from a slightly different angle. Rather than have one macro 'physically' change another you can use a 'switch'.
    Please Login or Register  to view this content.
    The idea is a Boolean variable is set to True only when Sub Two is run so your line of code will only run if Sub Two is run BEFORE Sub One.

    Is that of any help?

    BSB

  4. #4
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: Macro that can change a line of code in another macro

    depending on who is using the workbook depends on which is needed...sometimes I need it cleared sometimes not. That is why I would like to automate it rather than having to do it myself every time.....I am not always available.

  5. #5
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: Macro that can change a line of code in another macro

    As you can see the line I would like to change from time to time is at the bottom of this code.

    how would I incorporate the switch with the code to work??



    Please Login or Register  to view this content.

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Macro that can change a line of code in another macro

    I presume you have a button or similar to run the code above (without that line of code)?

    Will you have a separate button to run it WITH that line of code or another method?

    BSB

  7. #7
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: Macro that can change a line of code in another macro

    I have one button that runs the above code. I manually update it depending on whether I want the line commented or uncomment on the line.

    That is why I was thinking of a macro that could change that particular line just by activating that separate macro and still be able to use the existing macro to run the overall code.

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Macro that can change a line of code in another macro

    And how do you plan on activating that separate macro? A separate button?

    If yes then you'll have a macro run by that second button:
    Please Login or Register  to view this content.
    Then change this line in your existing macro:
    Please Login or Register  to view this content.
    To this
    Please Login or Register  to view this content.
    You still use your existing macro, but with that slight change.

    BSB

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Macro that can change a line of code in another macro

    Why not simply have a message box asking if you want to clear the cells?
    Please Login or Register  to view this content.

+ 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] Using one macro to change lines of code in a different macro
    By anorris_TSAV in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-13-2020, 07:37 AM
  2. Macro code to call a macro if a certain cell's value is change
    By mm671750 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2014, 12:37 PM
  3. Macro to add a line containing indirect, change sheet names in formula
    By bcas77 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2013, 01:20 PM
  4. Macro to change a row of dates in line with current month and year
    By widodude in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-02-2011, 06:50 AM
  5. Change first line of Module with Macro
    By Bravurian17 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-12-2009, 04:30 AM
  6. Create or change color of a (line with arrow head) with a Macro en
    By Ed in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2006, 07:10 PM
  7. Macro to change Macro code?
    By Kaisies in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2005, 11:07 PM

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