Macro code mod - add tabs/apply to entire workbook

T

teh_chucksta

Hi,

The macro below allows users to group/ungroup rows in a protected sheet.
Question: how to modify the VB code so I can incorporate additional tab names
or better yet, have the macro apply to the entire workbook?

Thanks in advance for your help,
Charlie


Sub workbook_open()
With Worksheets("Sheet1")
.Protect Password:="xlhelp", userinterfaceonly:=True
.EnableOutlining = True
End With
End Sub
 
B

Bob Phillips

Sub workbook_open()
For Each sh In Activeworkbook.Worksheets
With sh
.Protect Password:="xlhelp", userinterfaceonly:=True
.EnableOutlining = True
End With
Next sh
End Sub
 
P

Per Jessen

Hi

Try this:

Sub workbook_open()
for each sh in thisworkbook.sheets
if sh.name<>"NotThisSheet" then
With sh
.Protect Password:="xlhelp", userinterfaceonly:=True
.EnableOutlining = True
End With
end if
next
End Sub

Regards,
Per
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top