sub routine

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

First of all, please excuse the re-post, but I didn't receive a workable
answer to my original post. Please see below, Thanks....

We have a workbook with multiple worksheets. I have written a procedure
which checks for data outside of a specified range on the worksheet.

Is it possible to have this procedure run automatically whenever a user
activates a new worksheet in the workbook? I realize that the procedure can
be tied to a key combination, or command button, but that requires input from
the user. For this application, we need to automate the process.

Thanks,

Jim
 
Call your procedure from a Workbook_SheetActivate event. The
Workbook_SheetActivate must be in the ThisWorkbook module. In the Visual
Basic Editor, double-click on the ThisWorkbook module in the Project Explorer
(if you don't see the Project Explorer, select View >> Project Explorer).
There are two wide dropdown boxes across the top. In the left dropdown,
select Workbook. Then, in the right dropdown, select SheetActivate. This
creates a Workbook_SheetActivate event (with no code to do anything). Add a
Call statement to run your procedure. Make sure your procedure operates on
the ActiveSheet. Also, if your procedure is Private or is in the code module
for a particular worksheet, move it to ThisWorkbook or a general VBA module
and make it Public.

If you are relatively new to macros, this link to Jon Peltier's site may be
helpful:
http://peltiertech.com/WordPress/2008/03/09/how-to-use-someone-elses-macro/

Hope this helps,

Hutch
 
You were given a workable answer to your first post.

Jacob provided it.

You just did not follow his steps.


Gord Dibben MS Excel MVP
 
Back
Top