Announcement

Collapse
No announcement yet.

Run A Macro When Worksheet Opens

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    Re: Run A Macro When Worksheet Opens

    Shab,

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

    Code:
    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

    Comment


    • #3
      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.)
      Code:
      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.

      Comment


      • #4
        Re: Run A Macro When Worksheet Opens

        thanks people, thats worked fine now

        Shab

        Comment

        Working...
        X