+ Reply to Thread
Results 1 to 4 of 4

Calling subs

  1. #1
    Registered User
    Join Date
    12-10-2010
    Location
    Leuven, Belgium
    MS-Off Ver
    Excel 2007/2010
    Posts
    3

    Calling subs

    I try to set up a ribbon to improve the user interface of my excel sheet. The code generated by the Custom UI editor is located in a 'Module'.

    I want to call a sub located in the 'Workbook', from a Sub located in a 'Module', and get an error.

    What is the right way to call a sub in this situation ?

    'Callback for customButton1 onAction
    Please Login or Register  to view this content.


    with bigImport as the sub located in the Workbook.

    Thanks,

    François
    Last edited by fvmeul0; 12-10-2010 at 05:35 AM. Reason: add code tags for newbie mp warning

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Calling subs

    what do you mean by
    call a sub located in the 'Workbook',
    is that a sub in the ThisWorkbook module? If so, it can not be called by another procedure outside the ThisWorkbook module

    In the Sheet and ThisWorkbook modules, it's best to use only the event subs. All other subs should go into a standard module. You can not call subs in the Sheets or ThisWorkbook module from any other module. But procedures in a standard module can be called from any other sub.

    (as far as I'm aware)

    cheers, teylyn

  3. #3
    Registered User
    Join Date
    12-10-2010
    Location
    Leuven, Belgium
    MS-Off Ver
    Excel 2007/2010
    Posts
    3

    Re: Calling subs

    Thanks, I just had to relocate all the subs from the worksheet to a module. Now it works fine.

    Thanks a lot for this very fast answer.

    François

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Calling subs

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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