View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan[_2_] Rowan[_2_] is offline
external usenet poster
 
Posts: 226
Default Need Help - save sheet then hide when....

Bearing in mind that you can't save an individual worksheet - you have to
save the whole workbook - place this code in the ThisWorkbook code sheet in
your VBA project. It traps the event where a sheet is deactivated.

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
If Sh.Name = "Routes" Then
Sh.Visible = False
ActiveWorkbook.Save
End If
End Sub

Regards
Rowan

"Jan" wrote:

I am using Excel 2003 and I'm a novice with VBA.
I have 2 worksheets(for now): Steps and Routes.

I plan to have several command buttons on the Steps worksheet that when the
user clicks on the button, it unhides a worksheet and places the cursor in a
specific cell for that worksheet to allow the user to begin entering required
data. The macro I created for the button works so far to select the "Routes"
worksheet.

When the user is finish entering data and selects the "Steps" worksheet, I
want the Routes worksheet to be saved and then hidden. Can someone help me
with the syntax to accomplish this event?

TIA