+ Reply to Thread
Results 1 to 6 of 6

Worksheet Open Event

  1. #1
    Registered User
    Join Date
    12-18-2009
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    15

    Worksheet Open Event

    Hello,

    I am trying to run a macro each time a specific worksheet is opened.

    My worksheet is named 'Quote' and the macro I want to call is contained in a module. The macro is Update_quote().

    What would the code be? And where would I place the code?
    Last edited by muckem333; 01-27-2010 at 04:54 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Worksheet Open Event

    Hi,

    When you say worksheet do you really mean worksheet, or workbook? I ask since it's usual to Activate a worksheet and open a workbook.

    You need to use either the Worksheet_Activate event or the Workbook_Open event and put the Update_quote macro name in there.

    Rgds
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    12-18-2009
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Worksheet Open Event

    Awesome. That was simple enough!

    Thanks

  4. #4
    Registered User
    Join Date
    12-18-2009
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Worksheet Activate Event

    Richard,

    I have the Worksheet Activate working. Now I have another issue:

    I have an 'export' button which creates a copy of the worksheet in another workbook. Now, I am getting a "compile error: Sub or Function not defined" when I run the macro associated with the 'export' button.

    In this 'exported' copy I do not want the Worksheet_Activate code to copy over. Is there a way to either delete it or de-activate it when I create the copy?

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Worksheet Activate Event

    Hi,

    You can delete VBA code with
    Please Login or Register  to view this content.
    this same subject was covered in a similar thread a couple of days ago. See http://www.excelforum.com/excel-prog...n-copying.html

    HTH

  6. #6
    Registered User
    Join Date
    12-18-2009
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Worksheet Open Event

    Still getting the same error. Is this because when I copy the worksheet it is automatically activated, and hence, the first step it goes through is to call the worksheet_activate() macro? Calling this macro as soon as it is activated will call the Update_Quote() macro which will no longer be linked to appropriate references and cause the error. So where would I insert the delete VBA code? Or is there some way to get around this, like an if statement or Onerror?

+ 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