+ Reply to Thread
Results 1 to 5 of 5

Connecting button to macro

  1. #1
    april27
    Guest

    Connecting button to macro

    OK this does not sound very difficult but I have a problem finding the
    correct macro and how to connect it to the button. I have made a button from
    the View>Toolbars>Forms in Excel. Now I already have code that I have placed
    in a Modul. The only thing I want the button to do is to call a bigger
    program that is found in the modul when pressed. When I try to connect the
    button to desierd macro I do not succed to find the macro in the lis nor do
    any manual attempts work. Can someone please help me?

  2. #2
    kassie
    Guest

    RE: Connecting button to macro

    Right click on the button, click on View Code. You will see a procedure,
    most likely called Button1_Click(), with a blank line below that, and in the
    next line the words End Sub. In the blank line type in the name of the macro
    you want to run. Return to your sheet, and click on the Design button to
    exit Edit mode. If you click the button, it will run your macro.

    "april27" wrote:

    > OK this does not sound very difficult but I have a problem finding the
    > correct macro and how to connect it to the button. I have made a button from
    > the View>Toolbars>Forms in Excel. Now I already have code that I have placed
    > in a Modul. The only thing I want the button to do is to call a bigger
    > program that is found in the modul when pressed. When I try to connect the
    > button to desierd macro I do not succed to find the macro in the lis nor do
    > any manual attempts work. Can someone please help me?


  3. #3
    MaryR
    Guest

    RE: Connecting button to macro

    I coded a VBA Excel solution where a UserForm shows when the Workbook_Open
    occurs. Once the process finishes successfully, the workbook stays open with
    a button on the worksheet. It is in the worksheet, not the module, where
    your code goes. So, for instance, my Workbook_Open is this:

    Private Sub Workbook_Open()
    UserForm_HSIsplash.Show
    UserForm1.Show
    End Sub

    And the code for the button click on the Worksheet (I named the button
    "showUserForm1") is this:

    Private Sub showUserForm1_Click()
    Call UserForm1.UserForm_Initialize
    UserForm1.Show
    End Sub

    Hope this helps!

    --
    --Being powerful is like being a lady; if you have to tell people you are,
    you aren''t. ~~Margaret Thatcher


    "april27" wrote:

    > OK this does not sound very difficult but I have a problem finding the
    > correct macro and how to connect it to the button. I have made a button from
    > the View>Toolbars>Forms in Excel. Now I already have code that I have placed
    > in a Modul. The only thing I want the button to do is to call a bigger
    > program that is found in the modul when pressed. When I try to connect the
    > button to desierd macro I do not succed to find the macro in the lis nor do
    > any manual attempts work. Can someone please help me?


  4. #4
    Harald Staff
    Guest

    Re: Connecting button to macro

    Hi

    Are you able to run the macro with menu Tools > Macro > Run ? Which module
    is the macro in ?

    Best wishes Harald

    "april27" <[email protected]> skrev i melding
    news:[email protected]...
    > OK this does not sound very difficult but I have a problem finding the
    > correct macro and how to connect it to the button. I have made a button

    from
    > the View>Toolbars>Forms in Excel. Now I already have code that I have

    placed
    > in a Modul. The only thing I want the button to do is to call a bigger
    > program that is found in the modul when pressed. When I try to connect the
    > button to desierd macro I do not succed to find the macro in the lis nor

    do
    > any manual attempts work. Can someone please help me?




  5. #5
    kassie
    Guest

    RE: Connecting button to macro

    Press <Alt><F11> to go to VB. Find the macro you want to use, and remember
    this name. It could be in a module of its own - Module 1 most likely, or in
    This Workbook, or one of the worksheets. To move between these, double click
    on the name in the left hand window, and you will see code if any in the
    right hand window.
    Also, you should use View Toolbars Control Toolbox to create a button. Once
    you have the name of the macro, do as per my previous post.

    Kassie
    "april27" wrote:

    > OK this does not sound very difficult but I have a problem finding the
    > correct macro and how to connect it to the button. I have made a button from
    > the View>Toolbars>Forms in Excel. Now I already have code that I have placed
    > in a Modul. The only thing I want the button to do is to call a bigger
    > program that is found in the modul when pressed. When I try to connect the
    > button to desierd macro I do not succed to find the macro in the lis nor do
    > any manual attempts work. Can someone please help me?


+ 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