Consulting

Results 1 to 4 of 4

Thread: Solved: Creating a Button For A Workbook Macro

  1. #1
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location

    Solved: Creating a Button For A Workbook Macro

    I'm trying to make a button on the workbook that will activate a macro. I tried using Excel help but I still cant figure it out. I want this button to go with the workbook so others may use it when I send them the file. When you press the button I want it to call "Main" which runs the code.
    [VBA]Public Sub Main()
    Application.ScreenUpdating = False
    Dim rngStart As Range
    Set rngStart = Selection
    Sheets("Tables").Activate
    ' Sheets("Tables").Select
    First_Shift_Sort
    Flex_Shift_Sort
    Second_Shift_Sort
    SD_Sort

    With rngStart
    .Parent.Activate
    .Select
    End With
    Application.ScreenUpdating = True
    End Sub
    [/VBA]

    Thanks
    Gary

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    If you display the "Forms" toolbar, there is a button to create a command button, which you draw onto the worksheet. Once you've set the size and position of the button, it will prompt you for the name of the macro you want to link to.

  3. #3
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location

    Solved

    Thank you geekgirl I was able to get it done your way.

  4. #4
    Hey, geekgirlau, I tried out your suggestion (first time I've used the "Forms" toolbar), and the button is interesting, but perplexing. What kind of button is that? It doesn't seem to have the qualities of an AutoShape (which I prefer for buttons).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •