+ Reply to Thread
Results 1 to 11 of 11

Calling Sheet functions to Sub Workbook_Open Event??

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Calling Sheet functions to Sub Workbook_Open Event??

    Isn't there a way that I can call a sub from sheet 2 from ThisWorkbook? I made the sub public but I get an error right off the hop. I tried moving it to a regular module but then I get an error stating "Sub or Function not defined". I moved it to ThisWorkbook and get the same error. Possibilities?
    Last edited by Mordred; 07-29-2011 at 05:14 PM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Calling Sheet functions to Sub Workbook_Open Event??

    I'm going to go out on a limb and say no to all of the above.

  3. #3
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Calling Sheet functions to Sub Workbook_Open Event??

    Hi Mordred
    What is in the sub you are calling?
    You haven't got a syntax error or reference here that is causing the problem?
    Does the sub run OK directly from the VBE?
    How are you calling the sub?

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Calling Sheet functions to Sub Workbook_Open Event??

    Hi barryleajo, the sub I am calling works in the sheet and was private but I changed it to Public, still no! There are no syntax errors as it works in the sheet module.
    I tried a few different wayst to call it. For example:
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    All with no luck. Instead of trying to call the procedure I took the code within it and put it into the Private Sub Workbook_Open() event. Oh and that is where I was calling the sub from, the Private Sub Workbook_Open() event.

  5. #5
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Calling Sheet functions to Sub Workbook_Open Event??

    Whenever I have called subs with parameters I have always used the syntax
    Call ShowForm(True, True)
    (sorry about no code tags -iPad!!!!!)

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Calling Sheet functions to Sub Workbook_Open Event??

    I just tried that too and I still get error "Sub or Function not defined"

  7. #7
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Calling Sheet functions to Sub Workbook_Open Event??

    Try using different name for sub

  8. #8
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Calling Sheet functions to Sub Workbook_Open Event??

    I tried that too and I tried moving the sub into ThisWorkbook and then renaming it to no avail!

  9. #9
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Calling Sheet functions to Sub Workbook_Open Event??

    Happy to look at it in context with you if you upload your workbook?

  10. #10
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Calling Sheet functions to Sub Workbook_Open Event??

    That's alright barry, as I said I put the code into the workbook open event and everything is good, instead of calling it as a sub.

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

    Re: Calling Sheet functions to Sub Workbook_Open Event??

    If the code was in a worksheet code module, then you have to call it as a method of that sheet (using the sheet's code name):
    Please Login or Register  to view this content.
    for example.
    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