I am trying to write VB code to cause a Macro to run when a particular
worksheet is selected. How do I write this code and where do I place it?
I am trying to write VB code to cause a Macro to run when a particular
worksheet is selected. How do I write this code and where do I place it?
> I am trying to write VB code to cause a Macro to run when a particular
> worksheet is selected. How do I write this code and where do I place it?
The code is the same as any other VB code... whatever you need it to do.
You place it in the worksheet's code mudule...
In the VB window, press View-Project Explorer
Double click the sheet that you want the code to work with
Use the drop box in the upper left and select 'Worksheet'
Use the drop box in the upper right to select 'Activate'
When you do that, a subroutine will come up that looks like this:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Each time the sheet is activated, that code will run.
Think Mark copied the wrong event declaration:
Private Sub Worksheet_Activate()
End Sub
is what he describes.
--
Regards,
Tom Ogilvy
"mark" <[email protected]> wrote in message
news:[email protected]...
> > I am trying to write VB code to cause a Macro to run when a particular
> > worksheet is selected. How do I write this code and where do I place
it?
>
> The code is the same as any other VB code... whatever you need it to do.
>
> You place it in the worksheet's code mudule...
>
> In the VB window, press View-Project Explorer
> Double click the sheet that you want the code to work with
> Use the drop box in the upper left and select 'Worksheet'
> Use the drop box in the upper right to select 'Activate'
>
> When you do that, a subroutine will come up that looks like this:
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> End Sub
>
> Each time the sheet is activated, that code will run.
>
>
> Think Mark copied the wrong event declaration:
Yep, I sure did.
Thanks for the catch.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks