![]() |
Disable moving sheets
Hi All,
I wondered if there is a method to disable the moving of sheets other than protecting the workbook structure. Any code to achieve this would be gratefully appreciated TIA Michael B |
Disable moving sheets
Protecting the structure is the only direct method to control this. Using
code is simply defeated by disabling macros. In fact, if security is set to high and the macro is not certified and accepted by the user, then the macros would be disabled without the user even knowing it existed. there is no trappable event directly related to moving a worksheet. -- Regards, Tom Ogilvy "michael.beckinsale" wrote: Hi All, I wondered if there is a method to disable the moving of sheets other than protecting the workbook structure. Any code to achieve this would be gratefully appreciated TIA Michael B |
Disable moving sheets
Private Sub SetSheetOrder() 'Check Sheet Order Application.ScreenUpdating = False If Worksheets("Sheet2").Index = 1 Then If Worksheets("Sheet1").Index = 2 Then If Worksheets("Sheet3").Index = 3 Then Exit Sub End If End If 'Re-Order Sheets Worksheets("Sheet2").Move befo=Sheets(1) Worksheets("Sheet1").Move after:=Sheets(1) Worksheets("Sheet3").Move after:=Sheets(2) End Sub You could add as many layers as you want. If you need to make sure that they never change the sheets, run this sub in the Worksheet_Deactivate() sub of each sheet. If you just need to determine the sheet order before you run some of your own macros, you only need the Re-Order Sheets portion of the sub and you don't need to put it in each sheets Worksheet_Deactivate sub. On Aug 23, 8:08 am, "michael.beckinsale" wrote: Hi All, I wondered if there is a method to disable the moving of sheets other than protecting the workbook structure. Any code to achieve this would be gratefully appreciated TIA Michael B |
Disable moving sheets
Hi Don,
Many thanks for the code. It isn't quite what l want but l can adapt the concept to give me what l want. I wasn't aware of the .Index method Regards Michael B |
Disable moving sheets
On Aug 24, 3:06 am, "michael.beckinsale"
wrote: Hi Don, Many thanks for the code. It isn't quite what l want but l can adapt the concept to give me what l want. I wasn't aware of the .Index method Regards Michael B I never had an formal Excel training or education so there is probably a better way... Enjoy! |
All times are GMT +1. The time now is 02:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com