Create VBA code and place it inside Sheet module

  • Hi to all in forum,


    Having many activex buttons, I want to generate the code shown below to have all activex buttons associated
    with macro "Calculate" and put that needed codde automatically inside sheet1 module.



    So, is needed to get the name of each button (CommandButtonX) to generate each "Private" Sub Routine and be
    able to take each sub routine to sheet1 module.


    I hope make sense and somebody could help me.


    Any help would be very appreciated.

  • Re: Create VBA code and place it inside Sheet module


    You don't need the code in the sheet module.


    One macro in a Standard module & call it from the rquired buttons

  • Re: Create VBA code and place it inside Sheet module


    Would be much easier to use regular forms buttons:

    Code
    Sub test()Dim btn As Button
    For Each btn In Sheets(1).Buttons
        btn.OnAction = "Calculate"
    Next btn
    End Sub
  • Re: Create VBA code and place it inside Sheet module


    Hello to all, thanks for your help!


    Cytop,


    I'll check the link you give me. Thank you.


    Roy,


    May you give me an example of how to do it with a normal module please.
    But that is one part, the main part is how to generate the that will go inside
    The sheet module or standard module.


    Kyle,


    I'm not using form buttons because are needed buttons with different
    Colors and normal buttons I think only let you use gray :(.


    Thanks again for your help.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!