+ Reply to Thread
Results 1 to 4 of 4

Calling sub in a module from another sub

  1. #1
    Registered User
    Join Date
    08-06-2013
    Location
    Hawaii, US
    MS-Off Ver
    Excel 2013
    Posts
    13

    Calling sub in a module from another sub

    I'm having issues calling procedures that I created in modules from other procedures.

    For example, I have an ActiveX button in my worksheet with the following in the code to that specific worksheet:

    Sub ExampleButton_Click()
    Call ExampleSub
    End Sub

    And in a module, I've written:

    Sub ExampleSub()
    ...
    End Sub

    When I run the first sub, I get the following error:
    Compile error:
    Expected variable or procedure, not module

    I'm wondering if it has something to do with my macro settings (although I'm sure they're currently enabled), because I also have a splash screen (user form with info on it that runs when the application opens) that is set to kill at a certain time by running another procedure that unloads the userform. This procedure (KillForm) is saved in a module, as well, and called from another procedure. It is also not working.

    Thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Calling sub in a module from another sub

    What have you named the module with the ExampleSub in it?

    Hopes it's not ExampleSub.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Calling sub in a module from another sub

    While not the problem here, if you use Call, be sure to use ()'s if you have input parameters.
    e.g.
    Please Login or Register  to view this content.
    Last edited by Kenneth Hobson; 08-28-2013 at 02:30 PM.

  4. #4
    Registered User
    Join Date
    08-06-2013
    Location
    Hawaii, US
    MS-Off Ver
    Excel 2013
    Posts
    13

    Re: Calling sub in a module from another sub

    Quote Originally Posted by Norie View Post
    What have you named the module with the ExampleSub in it?

    Hopes it's not ExampleSub.
    Ha. Yep! Thanks for the fix!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help calling a module from a button click
    By jpalmos in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-24-2013, 03:16 PM
  2. Calling Another Sub in Another Module
    By Vladamir in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-19-2012, 05:47 PM
  3. Calling a Macro from module
    By peter.thompson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2006, 07:14 PM
  4. Calling worksheet module from other module.
    By Michael Malinsky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2005, 04:50 PM
  5. Help with Calling a Module within a Module
    By John in forum Excel General
    Replies: 2
    Last Post: 04-28-2005, 01:06 PM

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