how do i automatically run a macro when i move from one worksheet to another.
ie select another worksheet, then automatically run a specific macro
pat
Earl Kiosterud - 05 Sep 2007 23:46 GMT
Patrick,
Put this sub in the ThisWorkbook module. Sh will be the worksheet that was just activated.
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
MsgBox Sh.Name
' take out the line above and put in your code
End Sub

Signature
Earl Kiosterud
www.smokeylake.com
Note: Top-posting has been the norm here.
Some folks prefer bottom-posting.
But if you bottom-post to a reply that's
already top-posted, the thread gets messy.
When in Rome...
-----------------------------------------------------------------------
> how do i automatically run a macro when i move from one worksheet to another.
>
> ie select another worksheet, then automatically run a specific macro
>
> pat
Patrick - 06 Sep 2007 00:30 GMT
thanks
pat
> Patrick,
>
[quoted text clipped - 10 lines]
> >
> > pat
Gord Dibben - 05 Sep 2007 23:57 GMT
Private Sub Worksheet_Activate()
macroname
End Sub
This is sheet event code and goes into the sheet module of whichever sheet is be
activated for the macro to run.
Gord Dibben MS Excel MVP
>how do i automatically run a macro when i move from one worksheet to another.
>
>ie select another worksheet, then automatically run a specific macro
>
>pat
Patrick - 06 Sep 2007 00:26 GMT
cheers
works a treat.
programmming in access is so much easier than excell.
but unfortunately am having to use it
pat
> Private Sub Worksheet_Activate()
> macroname
[quoted text clipped - 10 lines]
> >
> >pat
Don Guillett - 05 Sep 2007 23:59 GMT
right click sheet tab>view code>left window select worksheet>right window
select sheet activate.

Signature
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com
> how do i automatically run a macro when i move from one worksheet to
> another.
>
> ie select another worksheet, then automatically run a specific macro
>
> pat