+ Reply to Thread
Results 1 to 5 of 5

Call Sub

  1. #1
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    105

    Call Sub

    I'm trying to call a sub routine in another spreadsheet but I keep getting a compile error "sub or function not defined." I have the following code:

    ...
    Please Login or Register  to view this content.
    ...

    Call DirectorFormat is giving me the error. I've also tried Call DirectorCopyFormat.DirectorFormat (DirectorCopyFormat is the module Directorformat sits in) but that gives me the same error. What am I doing wrong?
    Last edited by bishoposiris; 08-04-2009 at 10:15 AM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Call Sub

    You can't use Call if the macro is in another workbook, unless you have set a reference to that workbook's project. However, you can just use Application.Run instead.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    105

    Cool Re: Call Sub

    Thanks for your response. I tried:

    Application.Run (DirectorFormat)

    in place of Call DirectorFormat but I got a "variable not defined" error. Do I need to define a path to DirectorFormat or can I include the path in Application.Run?

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Call Sub

    It would be:
    Please Login or Register  to view this content.
    or if it's in mybook, you can use:
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Call Sub

    bishoposiris

    Please take a couple of minutes and read ALL theForum Rules then wrap your VBA code (Rule 3)
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

+ 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