referencing multiple worksheets in macro
So I kind of found the answer to my question in a post from a couple years
ago but am still confused so if anyone could help I'd appreciate it...I'm
trying to protect the sheet while still being able to use the subtotal
function. I have several worksheets I want to do this for and this is the
post from before with the code but I can't figure out where to put the names
of my worksheets ("01","02","03") and what I need to customize in the code
for my file. Any suggestions?
Option Explicit
Sub auto_open()
dim wks as worksheet
for each wks in thisworkbook.worksheets
with wks
.select 'see note below
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
.EnableAutoFilter = True
End With
application.goto thisworkbook.worksheets(1).range("a1"), scroll:=true
End Sub
Tom Ogilvy has reported that sometimes protecting sheets will work better if
it's selected first.
Change the application.goto line to where you want to goto <vbg when the
code
ends.
|