![]() |
vb code help
Hi how do I edit following code for multiple worksheets?
Option Explicit Sub auto_open() With Worksheets("sheet1") .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True '.EnableAutoFilter = True End With End Sub Thanks in advance.. |
vb code help
Hi,
If you want to do it to all the sheets in the workbook Private Sub Workbook_Open() Dim sh As Worksheet For Each sh In Worksheets With sh .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True .EnableAutoFilter = True End With Next sh End Sub You are using the Auto_Open subroutine, instead you should consider using the Workbook_Open() This code goes into the thisWorkbook object in the VBA editior. If this helps, please click the Yes button Cheers, Shane Devenshire "K-Man" wrote: Hi how do I edit following code for multiple worksheets? Option Explicit Sub auto_open() With Worksheets("sheet1") .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True '.EnableAutoFilter = True End With End Sub Thanks in advance.. |
vb code help
On Nov 21, 1:22 am, Shane Devenshire
wrote: Hi, If you want to do it to all the sheets in the workbook Private Sub Workbook_Open() Dim sh As Worksheet For Each sh In Worksheets With sh .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True .EnableAutoFilter = True End With Next sh End Sub You are using the Auto_Open subroutine, instead you should consider using the Workbook_Open() This code goes into the thisWorkbook object in the VBA editior. If this helps, please click the Yes button Cheers, Shane Devenshire "K-Man" wrote: Hi how do I edit following code for multiple worksheets? Option Explicit Sub auto_open() With Worksheets("sheet1") .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True '.EnableAutoFilter = True End With End Sub Thanks in advance.. Thanks Shane, It works great for the job I want to do..Thanks very much for the help.. Cheers, |
All times are GMT +1. The time now is 02:42 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com