+ Reply to Thread
Results 1 to 5 of 5

Calling function on button from excel sheet

  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    Pune
    MS-Off Ver
    Excel 2007
    Posts
    23

    Calling function on button from excel sheet

    Hi,

    I want to call a function on click of button (form control) in my excel sheet. I require this since i need to pass the cell references to the vba code on click of the button

    When I do assign macro to the button, it shows me only the sub procedure names in the vba code.

    Could anyone please guide me?


    Thanks,

    Shantanu

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Calling function on button from excel sheet

    if you are not returning a value you don't need a function you need a sub-subroutines can take arguments too! :-)

    however a sub that takes arguments will not appear in the macro list so you will have to manually input the routine name in the assign macro dialog and you will have to pass the reference as a string

    I reckon there are probably better ways to do this especially if the cell you want to use is related to the position of the button or can be otherwise determined in code
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    08-16-2012
    Location
    Pune
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Calling function on button from excel sheet

    Hi,

    Thanks for the reply.

    Could you guide me on a way where I can directly get the button position into the macro sub? If that happens, I would be more than happy.

    Till then I will continue with the way you suggested above

    Thanks,

    Shantanu

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Calling function on button from excel sheet

    to refer to the cell containing the top left corner of the shape you clicked
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-16-2012
    Location
    Pune
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Calling function on button from excel sheet

    Thanks a lot

+ 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