Announcement

Collapse
No announcement yet.

Referring to current worksheet in VBA

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Referring to current worksheet in VBA



    I have the following macro:

    Code:
    Private Sub Workbook_Open()
        With Sheet1
           .Protect Password:="Secret", UserInterfaceOnly:=True
           .EnableOutlining = True
        End With
    End Sub
    How do I instead of referring to "Sheet1" have it apply to the active worksheet?

  • #2
    Re: Referring to current worksheet in VBA

    Hi,

    Code:
    Private Sub Workbook_Open() 
        With Activesheet
            .Protect Password:="Secret", UserInterfaceOnly:=True 
            .EnableOutlining = True 
        End With 
    End Sub

    Cheers
    Andy

    Comment


    • #3


      Re: Referring to current worksheet in VBA

      perfect, thanks.

      Comment

      Working...
      X