#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default 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..
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default 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..

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default 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,
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
Unprotect Code Module in Code Damien Excel Discussion (Misc queries) 2 April 18th 06 03:10 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
Write a code by code Excel Discussion (Misc queries) 1 March 23rd 05 02:34 PM


All times are GMT +1. The time now is 09:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"