Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 4 of 4

Thread: Run A Macro When Worksheet Opens

  1. #1
    Join Date
    24th June 2005
    Posts
    46

    Run A Macro When Worksheet Opens

    Hello

    I have worksheet with a macro and currently if I run the macro using the play button and then select the macro it runs fine but what i want it to do is run when i open the workbook automatically.

    can someone show me how to do this?

    Shab

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    27th June 2004
    Location
    Atlanta, Georgia (USA)
    Posts
    164

    Re: Run A Macro When Worksheet Opens

    Shab,

    In the VBA editor, put the following code in the "This Workbook" sheet:

    VB:
    Private Sub Workbook_Open() 
        MsgBox "I just opened my workbook" 
    End Sub 
    
    
    then save the workbook, close it, and open it again to see if this is what you want.

    If so, replace the msgbox line with your code.

    Far Farley

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    22nd April 2003
    Location
    Virginia, USA
    Posts
    5,035

    Re: Run A Macro When Worksheet Opens

    If your macro is named "checkRanges" then place the following macro in the ThisWorkbook modukle. (It must be in this module to work.)
    VB:
    Private Sub Workbook_Open() 
        Call CheckRanges 
    End Sub 
    
    
    Replace "CheckRanges" with the name of your macro (that can/should be in a general code module.
    Best Regards,
    Tom
    ---------------------------
    Please help Oz share knowledge among all users by posting your questions in a public forum rather than using a Private Message.

  4. #4
    Join Date
    24th June 2005
    Posts
    46

    Re: Run A Macro When Worksheet Opens

    thanks people, thats worked fine now

    Shab

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Replies: 2
    Last Post: February 15th, 2006, 05:53
  2. VBA editor opens when macro initiated
    By Arce2ee in forum EXCEL HELP
    Replies: 4
    Last Post: December 31st, 2005, 20:26
  3. VBE Window opens every time I run a macro
    By quaker5567 in forum EXCEL HELP
    Replies: 9
    Last Post: October 31st, 2005, 13:15
  4. Replies: 7
    Last Post: August 13th, 2004, 04:11
  5. Excel opens into VisB
    By TeachingMudd in forum EXCEL HELP
    Replies: 9
    Last Post: February 4th, 2003, 01:51

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
  •  
porno