Need Before_Save code
Phil,
The "ThisWorkbook" module is where the workbook "Event" code
is placed. With the ThisWorkbook module open, click the left
dropdown and select workbook and in the right dropdown, you can
see all of the events.
There are Sheet Modules too for coding the events specific to the
individual sheets.
Regular modules are for general coding for use anywhere in the
workbook.
Having said the above, were you to take the code that I gave
you (actually, use Trevors as it's more concise) and place it
in the Workbook_Open Event, (in the "ThisWorkbook" module,
it would work there too.
Example:
Private Sub Workbook_Open()
' Trevor's code
Application.ScreenUpdating = False
Worksheets(Array("Employee", "Customer", "Finance", "Scorecard")).Select
Range("A1").Select
Worksheets("Scorecard").Select
Application.ScreenUpdating = True
End Sub
John
Phil Hageman wrote:
Thanks, John - it works perfectly. A final question:
what is the difference between using "ThisWorkbook", and a
new "Module1"?
-----Original Message-----
Phil,
It shouldn't go in the "ThisWorkbook" module.
Right click on "ThisWorkbook" in the "Projects" window
and then choose "Insert/Module".
Paste it into the module that appears to the right.
John
Phil Hageman wrote:
John, Thanks for your reply. I copy/pasted the code
into
the "This Workbook" module, but it doesn't work. There
is
no error message to hint of the problem either. Is
there
something I should look for?
Thanks, Phil
-----Original Message-----
Phil,
If, as you say, you want a standard set-up when the
user
"opens" the workbook, a simple way would be as follows:
Sub Auto_Open()
Application.ScreenUpdating = False
Worksheets("Employee").Activate
Range("A1").Activate
Worksheets("Customer").Activate
Range("A1").Activate
Worksheets("Finance").Activate
Range("A1").Activate
Worksheets("Scorecard").Activate
Range("A1").Activate
Application.ScreenUpdating = True
End Sub
The above macro, when placed in a regular module, will
run whenever
the workbook is opened and insure that "Scorecard" is
the
active sheet
and that cell "A1" is the active cell on all the
sheets.
John
Phil Hageman wrote:
My workbook is named Scorecard, and its worksheets
are
entitled Scorecard, Customer, Finance, and Employee.
When the user clicks the Save icon, I want the
cursor in
each worksheet to be placed in Cell A1, and the
worksheet
named Scorecard to be the the last worksheet changed.
The object is that when a another user first opens
the
Workbook, the worksheet named Scorecard comes up
first,
and as each of the other worksheets is opened, it
shows
the top of the worksheet - thus the force of cursor
to
cell A1.
Thanks, Phil
.
.
|