+ Reply to Thread
Results 1 to 5 of 5

Copying ActiveX Command Button from master sheet to subsheets. command button code missing

  1. #1
    Registered User
    Join Date
    12-12-2020
    Location
    southampton
    MS-Off Ver
    365
    Posts
    11

    Copying ActiveX Command Button from master sheet to subsheets. command button code missing

    Hi, been searching for an answer on this. probably simple or a limitation but i cant work it out

    i have a master sheet that i copy into other subsheets. the master sheet has formula's that work on new pasted dated. it all works fine.

    I added some Active X Command buttons to the master sheet for filtering and when i create the subsheet the buttons get copied across but i lose the command button code in the original master sheet.

    Example of master sheet code for TWO buttons are:

    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    I have done the same for not active x buttons, being Form Control buttons and the button code IS copied across

    Active X Command Button code isn't copied across. please help driving me mad

    Paul
    Last edited by 6StringJazzer; 12-12-2020 at 12:50 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,675

    Re: Copying ActiveX Command Button from master sheet to subsheets. command button code mis

    ActiveX controls don't bring the code with them. I haven't tried this with Form controls but generally Form controls are linked to a Sub and I would expect copies of the controls to be linked to the same Sub but not for Sub itself to be copied. The two use different mechanisms for events: Forms buttons are explicitly linked to a Sub but ActiveX buttons use callbacks that are supported in VBA. You can name a sub for a Forms button anything you want as long as it's a Public Sub in a standard module. The Sub for ActiveX controls must have specific names and be in the same module where the button lives.

    If you make a copy of the entire worksheet, instead of copying the contents of the worksheet to other sheets, then the code will also be copied along with the buttons.

  3. #3
    Registered User
    Join Date
    12-12-2020
    Location
    southampton
    MS-Off Ver
    365
    Posts
    11

    Re: Copying ActiveX Command Button from master sheet to subsheets. command button code mis

    big thanks for this. Yep, basically I moved "adding the buttons" from the last thing executed in my suite of functions, to the first thing. I created a master form with the buttons in a "safe area" where they wouldn't be overwritten with pasted new data.

    I created another button/macro that copies the entire master worksheet (with the active x command buttons) to a new sheet (renaming it) and then carried on with the rest of the functions in the new sheet as before. At the end, i added more code to move the buttons that are in the safe area of the new sheet into the correct position on the new sheet.

    it doesn't seem the most elegant manner (looks more like a redneck hoedown) but it works and will do until I learn more about VBA, buttons etc. where it may look more like a waltz.

    thanks again. you have saved me hours.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,675

    Re: Copying ActiveX Command Button from master sheet to subsheets. command button code mis

    I'm glad I saved you time even if I feel like I didn't do anything :-) If you need further help you can also attach your file here for more specific diagnosis and suggestions.

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

  5. #5
    Registered User
    Join Date
    12-12-2020
    Location
    southampton
    MS-Off Ver
    365
    Posts
    11

    Re: Copying ActiveX Command Button from master sheet to subsheets. command button code mis

    the answer was what was needed. once i know the individual copy couldn't be done, it was easier to think of alternatives. it prompted me to work out an initial set-up routine. thanks again and changing to "solved"

+ 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] Command Button vs ActiveX Button Causing System Resource Drain
    By Logit in forum Excel General
    Replies: 0
    Last Post: 02-13-2019, 11:49 AM
  2. ActiveX Command Button combined with ActiveX List Boxes – VBA Code Needed
    By Stlcards13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2017, 02:56 PM
  3. [SOLVED] ActiveX command button open sheet
    By ricklou in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-30-2017, 03:51 AM
  4. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  5. [SOLVED] Conditionally Hide or deactivate code in an activeX command Button.
    By Kramxel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-26-2014, 12:19 PM
  6. Master Command Button to call on other Command Buttons located in other Workbooks
    By MrNickRegan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2013, 07:57 PM
  7. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 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