How would this work deliberately naming a sheet, pls?

  • Thread starter StargateFanFromWork
  • Start date
S

StargateFanFromWork

I've been using this neat new code given to me last week for "protecting" a
sheet yet allowing vb functions to work:
*****************************************************************************************************
With ActiveSheet
.EnableAutoFilter = True
.Protect UserInterfaceOnly:=True
End With
*****************************************************************************************************
This does, indeed, do the job.

I have a new workbook that needs adjusting that doesn't have a bunch of
commandbar code, etc., so I can just add an Auto_Open with the above code
in. But this just needs to be applied to "sheet2". Can someone kindly pls
provide the code for "sheet2" vs "ActiveSheet"?

Thanks. :blush:D
 
G

Guest

Since the code name for the sheet is in all likelyhood Sheet2 you could just
do...

With Sheet2
.EnableAutoFilter = True
.Protect UserInterfaceOnly:=True
End With

The code name is what you see in the VBE project explorer something like
this...

Sheet2(My Tab Name)

You can change sheet 2 to something more descripitve by changing the (Name)
property for the sheet. The name property is the firts property in the list.
 
G

Guest

With Sheet2
.EnableAutoFilter = True
.Protect UserInterfaceOnly:=True
End With

or if that is the tab name


With Worksheets("Sheet2")
.EnableAutoFilter = True
.Protect UserInterfaceOnly:=True
End With
 

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