View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Auto insert/delete on other sheet

I don't think you can lock it, you might be able to write code in the
activate event of sheet1 to reestabish it.

Just be aware that almost any changes you make to sheet1 will happen to
sheet 2 also.

Right click on the sheet tab of Sheet1 and select view code. Put in this
code:

Private Sub Worksheet_Activate()
Application.EnableEvents = False
Worksheets(Array("Sheet1", "Sheet2")).Select
Application.EnableEvents = True
End Sub

In the Thisworkbook module (in the vbe (Alt+F11), for you workbook, double
click on the ThisWorkbook entry and in the module put in this code)

Private Sub Workbook_Open()
Application.EnableEvents = False
Worksheets(Array("Sheet1", "Sheet2")).Select
Application.EnableEvents = True
End Sub

You could repeat the first code for Sheet2 if you never want to be able to
go to sheet2 but always had it grouped Then you could run code like this
to get to it yourself

Sub GotoSheet2()
Application.EnableEvents = False
worksheets("Sheet2").Activate
Application.EnableEvents = True
End Sub



--
Regards,
Tom Ogilvy



"broogle" wrote in message
ups.com...
Hi Tom !
It works !! Thank you.
Is it possible to lock this grouping, just in case someone will
accidently select ungroup?
Thanks again Tom.