+ Reply to Thread
Results 1 to 5 of 5

Help with Calling Routines

  1. #1
    Registered User
    Join Date
    05-17-2011
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2007
    Posts
    9

    Help with Calling Routines

    Hi Everyone

    I have a routine in Excel 2007 in the 'Sheet1' object. This routine calls another routine "Sub NotifyIT()" which is in the stored in the 'ThisWorkbook' object.

    I am getting a compile error "Sub or Function not Defined" at this line of my code:

    Call NotifyIT

    The "NotifyIT" routine can be called by both the routine in Sheet1 or by the BeforePrint event. Is there a way both can call the NotifyIT routine without me having two copy it to both objects?

    Thanks!

    HappyHole

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Help with Calling Routines

    Hi HappyHole,

    You need to read this from the first sentence. It speaks to your problem
    http://www.cpearson.com/excel/codemods.htm
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    05-17-2011
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Help with Calling Routines

    Thanks Marvin, that is helpful.
    The original routine controls lots of shapes and objects on Sheet1. I can move the code into a Standard Code Module but presumably then need to add sheet name references to all the instances of code that refer to an object sitting in sheet one right?

    Thanks.

    HH

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Help with Calling Routines

    You can use ActiveSheet in a Module and it will simply work on the one that is being viewed.

    It all depends on your code....

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

    Re: Help with Calling Routines

    More to the point, move NotifyIT to a normal module. You can then call it from the Sheet1 code.
    Remember what the dormouse said
    Feed your head

+ 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