View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
PCLIVE PCLIVE is offline
external usenet poster
 
Posts: 168
Default If activesheet is called X, then do y

One way I think will work is:

if activesheet.name = "dogs" then GetDogs
if activesheet.name = "cats" then GetCats

However, when is this code supposed to run. Is it based on anytime the
sheet is active, or is it dependent on some other code that runs?
If it is to run any time those sheets are activated then you could add code
specifically to that sheet.
For example:

Right-click on sheet "dogs" and select View code. Click General dropdown
and select Worksheet. Click other dropdown and make sure it is on
Activate".
Then in your code, enter the macro name you want to run when this sheet is
selected. Here's what it would look like:

Private Sub Worksheet_Activate()
GetDogs
End Sub


HTH,
Paul


"Darin Kramer" wrote in message
...

Hi guys,

I need some VBA that says if the active sheet is "dogs", then call macro
entitled get dogs. If active sheet is "cats", then call macro entitled
"get Cats".

Possible...?

Thanks!!

D


*** Sent via Developersdex http://www.developersdex.com ***