+ Reply to Thread
Results 1 to 5 of 5

run macro on workbook open

  1. #1
    kevin
    Guest

    run macro on workbook open

    Hi,

    I have a macro that sorts a table. what do i need to do to have this macro
    run every time the workbook is opened? is it simply run XYZ() under the
    object this workbook?

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning Kevin

    Two ways of doing this:

    The old way - this method was the way to do it pre XL97 but still works OK for compatibility purposes. Call your macro auto_open(). And that's it.

    The new way - with XL97 onwards came event procedures. You could call your macro workbook_open() and drop it into the "This Workbook" event in the VBE.

    Either of those will do.

    HTH

    DominicB

  3. #3
    Kassie
    Guest

    RE: run macro on workbook open

    In Excel, press <Alt><F11>, type in Workbookopen and click on search

    "kevin" wrote:

    > Hi,
    >
    > I have a macro that sorts a table. what do i need to do to have this macro
    > run every time the workbook is opened? is it simply run XYZ() under the
    > object this workbook?


  4. #4
    Kassie
    Guest

    RE: run macro on workbook open

    Sorry, once in VB, click on <F1>, and then do the typing

    "kevin" wrote:

    > Hi,
    >
    > I have a macro that sorts a table. what do i need to do to have this macro
    > run every time the workbook is opened? is it simply run XYZ() under the
    > object this workbook?


  5. #5
    Harald Staff
    Guest

    Re: run macro on workbook open

    Almost:

    Private Sub Workbook_Open()
    Call XYZ
    End Sub

    in the ThisWorkbook module

    HTH. Best wishes Harald

    "kevin" <[email protected]> skrev i melding
    news:[email protected]...
    > Hi,
    >
    > I have a macro that sorts a table. what do i need to do to have this macro
    > run every time the workbook is opened? is it simply run XYZ() under the
    > object this workbook?




+ 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