+ Reply to Thread
Results 1 to 4 of 4

Run a macro when a Worksheet is clicked/activated

  1. #1
    Warren McGoldrick
    Guest

    Run a macro when a Worksheet is clicked/activated

    Hi,

    I'm looking for code that runs a macro when a worksheet called "email" is
    clicked everytime. I think it's an event macro, but, I can not seem to find
    an example.

    The macro I want to run is simple

    Sheets("email").Select
    Range("A1").Select
    Application.CutCopyMode = False
    ActiveWindow.ScrollRow = 1
    ActiveWindow.ScrollColumn = 1

    Thanks in advance.

    Wazza McG



  2. #2
    Gareth
    Guest

    Re: Run a macro when a Worksheet is clicked/activated

    Rightclick on the Email sheet tab and select "View Code".

    From the drop down boxes above select Worksheet (from the left) and
    Activate (from the right). This should create a procedure for you thus:

    Private Sub Worksheet_Activate()

    End Sub

    Insert your code here in there e.g.

    Private Sub Worksheet_Activate()
    msgbox "I'm clicked"
    End Sub

    It will then fire every time the worksheet is activated. If that
    Activates isn't what you're after, try Worksheet_SelectionChange or
    maybe a combination of the two.

    HTH,
    Gareth

    Warren McGoldrick wrote:
    > Hi,
    >
    > I'm looking for code that runs a macro when a worksheet called "email" is
    > clicked everytime. I think it's an event macro, but, I can not seem to find
    > an example.
    >
    > The macro I want to run is simple
    >
    > Sheets("email").Select
    > Range("A1").Select
    > Application.CutCopyMode = False
    > ActiveWindow.ScrollRow = 1
    > ActiveWindow.ScrollColumn = 1
    >
    > Thanks in advance.
    >
    > Wazza McG
    >
    >


  3. #3
    Wazza McG
    Guest

    Re: Run a macro when a Worksheet is clicked/activated

    Thankyou Thankyou Thankyou
    Gee that was simple!
    Much appreciated, I have never used those View Code sheets before - great
    stuff.

    Wazza McG




    "Gareth" <[email protected]> wrote in message
    news:[email protected]...
    > Rightclick on the Email sheet tab and select "View Code".
    >
    > From the drop down boxes above select Worksheet (from the left) and
    > Activate (from the right). This should create a procedure for you thus:
    >
    > Private Sub Worksheet_Activate()
    >
    > End Sub
    >
    > Insert your code here in there e.g.
    >
    > Private Sub Worksheet_Activate()
    > msgbox "I'm clicked"
    > End Sub
    >
    > It will then fire every time the worksheet is activated. If that Activates
    > isn't what you're after, try Worksheet_SelectionChange or maybe a
    > combination of the two.
    >
    > HTH,
    > Gareth
    >
    > Warren McGoldrick wrote:
    >> Hi,
    >>
    >> I'm looking for code that runs a macro when a worksheet called "email" is
    >> clicked everytime. I think it's an event macro, but, I can not seem to
    >> find an example.
    >>
    >> The macro I want to run is simple
    >>
    >> Sheets("email").Select
    >> Range("A1").Select
    >> Application.CutCopyMode = False
    >> ActiveWindow.ScrollRow = 1
    >> ActiveWindow.ScrollColumn = 1
    >>
    >> Thanks in advance.
    >>
    >> Wazza McG




  4. #4
    Gareth
    Guest

    Re: Run a macro when a Worksheet is clicked/activated

    You're welcome!

    Wazza McG wrote:
    > Thankyou Thankyou Thankyou
    > Gee that was simple!
    > Much appreciated, I have never used those View Code sheets before - great
    > stuff.
    >
    > Wazza McG
    >
    >
    >
    >
    > "Gareth" <[email protected]> wrote in message
    > news:[email protected]...
    >
    >>Rightclick on the Email sheet tab and select "View Code".
    >>
    >>From the drop down boxes above select Worksheet (from the left) and
    >>Activate (from the right). This should create a procedure for you thus:
    >>
    >>Private Sub Worksheet_Activate()
    >>
    >>End Sub
    >>
    >>Insert your code here in there e.g.
    >>
    >>Private Sub Worksheet_Activate()
    >>msgbox "I'm clicked"
    >>End Sub
    >>
    >>It will then fire every time the worksheet is activated. If that Activates
    >>isn't what you're after, try Worksheet_SelectionChange or maybe a
    >>combination of the two.
    >>
    >>HTH,
    >>Gareth
    >>
    >>Warren McGoldrick wrote:
    >>
    >>>Hi,
    >>>
    >>>I'm looking for code that runs a macro when a worksheet called "email" is
    >>>clicked everytime. I think it's an event macro, but, I can not seem to
    >>>find an example.
    >>>
    >>>The macro I want to run is simple
    >>>
    >>> Sheets("email").Select
    >>> Range("A1").Select
    >>> Application.CutCopyMode = False
    >>> ActiveWindow.ScrollRow = 1
    >>> ActiveWindow.ScrollColumn = 1
    >>>
    >>>Thanks in advance.
    >>>
    >>>Wazza McG

    >
    >
    >


+ 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