Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 3 of 3

Thread: Referring to current worksheet in VBA

  1. #1
    Join Date
    29th September 2005
    Location
    SLO
    Posts
    509

    Referring to current worksheet in VBA

    I have the following macro:

    VB:
    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?

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,310

    Re: Referring to current worksheet in VBA

    Hi,

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

    Cheers
    Andy


  3. #3
    Join Date
    29th September 2005
    Location
    SLO
    Posts
    509

    Re: Referring to current worksheet in VBA

    perfect, thanks.

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Replies: 2
    Last Post: December 19th, 2007, 00:00
  2. Created Named Ranges Referring to Wrong Worksheet
    By abundant_lyfe in forum EXCEL HELP
    Replies: 4
    Last Post: August 23rd, 2007, 17:53
  3. If Statement Referring To Another Worksheet
    By Lil in forum EXCEL HELP
    Replies: 11
    Last Post: March 8th, 2007, 12:33
  4. Replies: 3
    Last Post: July 26th, 2006, 23:14
  5. Copy current row to different worksheet
    By JMAN in forum EXCEL HELP
    Replies: 17
    Last Post: February 9th, 2006, 06:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
porno