+ Reply to Thread
Results 1 to 3 of 3

Macro to add another Macro to a button to add into a larger Macro.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Macro to add another Macro to a button to add into a larger Macro.

    I have a macro that creates a table of contents. I want a button to be placed at H2 that runs another macro I have.

    So macro - table of contents and part of that TOC is a button to run a macro to make a copy.

    The button will run this


    Sub CopyBlankPDA()
    '
    ' BlankCopy Macro
    '
    
    '
        Sheets("0Blank").Select
        Sheets("0Blank").Copy Before:=Sheets(4)
    End Sub



    I did a record and if it helps this is what it says,


    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
        ActiveSheet.Buttons.Add(361.5, 15.75, 111, 12.75).Select
        Selection.OnAction = "PERSONAL2.xlsm!CopyBlankPDA.CopyBlankPDA"
        Selection.Characters.Text = "Blank PDA Log"
        With Selection.Characters(Start:=1, Length:=13).Font
            .Name = "Calibri"
            .FontStyle = "Regular"
            .Size = 11
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = 1
        End With
        Range("I2").Select
    End Sub
    Last edited by taylorsm; 11-03-2016 at 10:30 AM.

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

    Re: Macro to add another Macro to a button to add into a larger Macro.

    Sub Macro1()
        With Range("H2")
            With ActiveSheet.Buttons.Add(.Left, .Top, .Width, .Height)
                .OnAction = "PERSONAL2.xlsm!CopyBlankPDA.CopyBlankPDA"
                .Characters.Text = "Blank PDA Log"
                With .Characters(Start:=1, Length:=13).Font
                    .Name = "Calibri"
                    .FontStyle = "Regular"
                    .Size = 11
                    .Strikethrough = False
                    .Superscript = False
                    .Subscript = False
                    .OutlineFont = False
                    .Shadow = False
                    .Underline = xlUnderlineStyleNone
                    .ColorIndex = 1
                End With
            End With
        End With
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to add another Macro to a button to add into a larger Macro.

    That is amazing. Thank you!

+ 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. Excel Upgrade to 2013, Macro runs erratically with macro assigned to button (shape)
    By sspatriots in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-17-2016, 07:23 PM
  2. [SOLVED] Using macro to create a Form Control Button and Assign macro to it in a specified Cell
    By weige1989 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-30-2014, 11:51 AM
  3. Using a macro on workbook1 to create a button in wb2 and assigning macro "wb2!macro"
    By penfold1992 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2014, 11:39 AM
  4. [SOLVED] Macro to change shape/macro button colours based on selection
    By deanstein in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-15-2013, 08:26 AM
  5. [SOLVED] Macro button copies sheet containing a macro button as an image
    By namso1902 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2013, 03:51 PM
  6. Replies: 0
    Last Post: 01-15-2013, 08:18 PM
  7. A macro to create a form button, assign a macro and name the button
    By cl361 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2008, 01:07 AM

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