none
Creating macros at sheet level RRS feed

  • Question

  • Hi,

    When we assign a macro to button in excel,It will create a new module and place the handler in it

    Can you please let me how to create macro at sheet level ? I mean to say,The handle should be placed at sheet level like sheet1,sheet2 ?

    Any help in this is greatly appreciated !!

    Thanks!!

    Santosh Sutar 

    Tuesday, May 12, 2015 4:34 PM

Answers

  • Hello,

    There are 2 kind of buttons:

    -Form control: places a handle by default in your module. You can change the location by doing the following:

    • place your code where you want
    • change the reference of the button-> go in design mode -> right click your button -> "assign macro"  -> change text to "Sheet1.Button2_Click"

    -Active X control: places a handle by default on you sheet.

    Hope this helps

    • Marked as answer by santosh sutar Wednesday, May 13, 2015 11:07 AM
    Wednesday, May 13, 2015 10:58 AM

All replies

  • Hi

    Your information is not exactly right and maybe you should tell us what you're trying to do.

    Have a look at the two links, that should help you.

    http://www.mcgimpsey.com/excel/modules.html
    http://www.contextures.com/xlvba01.html


    Cimjet

    Tuesday, May 12, 2015 5:02 PM
  • Thanks Cimjet for your time.

    I mean to say,When i assign a macro to a button, a handled will be created in the new module as below

    

    I would like to place the handler "Button2_Click" at sheet level like "Sheet1" 

    Can you please suggest on this ?

    Thanks!!

    Santosh Sutar

    Wednesday, May 13, 2015 9:34 AM
  • Hello,

    There are 2 kind of buttons:

    -Form control: places a handle by default in your module. You can change the location by doing the following:

    • place your code where you want
    • change the reference of the button-> go in design mode -> right click your button -> "assign macro"  -> change text to "Sheet1.Button2_Click"

    -Active X control: places a handle by default on you sheet.

    Hope this helps

    • Marked as answer by santosh sutar Wednesday, May 13, 2015 11:07 AM
    Wednesday, May 13, 2015 10:58 AM
  • Thanks Defour for you answer
    Wednesday, May 13, 2015 11:07 AM