+ Reply to Thread
Results 1 to 3 of 3

Write and assign macro to newly created button using macro

  1. #1
    Registered User
    Join Date
    05-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Write and assign macro to newly created button using macro

    I have attached a sample workbook with the code I am using. It works well, but now I need to have it write the macro to open the new sheet and assign the macro to the button it has just created. Can anyone help please.
    Attached Files Attached Files

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Write and assign macro to newly created button using macro

    You need to set the OnAction property of the newly created button. You get this to run an existing macro which takes part of the buttons name to determine which sheet to activate.

    Add this routine to a standard code module.
    Please Login or Register  to view this content.
    Alter you code
    Please Login or Register  to view this content.
    Not all names will result in valid sheetnames so you may need to handle that
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    05-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Write and assign macro to newly created button using macro

    Works perfectly. Thank you Andy.

+ 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