+ Reply to Thread
Results 1 to 4 of 4

Automatically open to certain tab / Hide Sheet / Password Protect / Run macro on start up

Hybrid View

b0whel01 Automatically open to certain... 09-23-2013, 12:56 PM
Dimitrov Re: Automatically open to... 09-23-2013, 10:20 PM
tuongtu3 Re: Automatically open to... 09-23-2013, 10:33 PM
Dimitrov Re: Automatically open to... 09-23-2013, 11:49 PM
  1. #1
    Registered User
    Join Date
    09-23-2013
    Location
    Louisville
    MS-Off Ver
    Excel 2010
    Posts
    4

    Automatically open to certain tab / Hide Sheet / Password Protect / Run macro on start up

    Hello - if you could please help with writing code to perform the following functions?

    1.Excel sheet that automatically opens to a tab called SR each time the workbook is opened
    2.Additionally everytime the workbook is opened, I would like tab named IR to be hidden
    3.When user manually unhides IR tab, a password is prompted every time to see the details within the IR spreadsheet.
    4.Password = 1234


    Also, do I paste in (Thisworkbook) within vba?

  2. #2
    Forum Contributor
    Join Date
    05-08-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    102

    Re: Automatically open to certain tab / Hide Sheet / Password Protect / Run macro on start

    b0whe01,

    Paste the following code into the ThisWorkbook object (not a regular module):

    Sub Workbook_Open()
    
    Worksheets("SR").Activate
    
    If Worksheets("IR").Visible = True Then
        Worksheets("IR").Visible = False
    End If
    
    End Sub
    This hides the IR tab upon on opening (if it is not already hidden).

    I will need to come back to the second part which deals with the password to the IR tab.
    __________________
    [1] If this reply was helpful, click the star to the left.
    [2] If this reply answered your question, then mark this thread as [SOLVED].
    Last edited by Dimitrov; 09-23-2013 at 11:18 PM.

  3. #3
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    818

    Re: Automatically open to certain tab / Hide Sheet / Password Protect / Run macro on start

    Hi b0whel01,
    Try the sample in attached.

    Regards,
    tt3
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    05-08-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    102

    Re: Automatically open to certain tab / Hide Sheet / Password Protect / Run macro on start

    b0whel01

    Here is my approach for dealing with building in a password to the IR tab. If a user attempts to unhide the tab (for example, by right clicking any of the other active tabs, selecting the Unhide option, selecting IR, and clicking OK), then the user will be prompted to enter a password. The drawback of my approach is threefold. First, while the user is prompted for the password, he or she can see a portion of the IR tab. Second, each time you click away and back to the IR tab, you will be prompted for the password. Third, if someone is sufficiently familiar with VBA, he or she can discover the password by going into the VBE. If you are comfortable with these three drawback, then paste this code into the IR object in VBE (instead of a regular module).

    Sub Worksheet_Activate()
    
        If Application.InputBox _
            (Prompt:="Enter the password.", _
            Title:="Sheet Protected", _
            Type:=2) <> "1234" Then
                Worksheets("IR").Visible = False
                Worksheets("SR").Activate
        Else
            Worksheets("IR").Visible = True
            Worksheets("IR").Activate
        End If
    
    End Sub
    _______________________
    [1] If this reply was helpful, click the star to the left.
    [2] If this reply answered your question, mark this thread as [SOLVED].

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to filter and protect sheet with password
    By GregTheSquarePeg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-10-2013, 05:42 AM
  2. Replies: 2
    Last Post: 01-17-2013, 08:39 AM
  3. [SOLVED] Problem with script to password protect and hide a sheet
    By macross in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2012, 12:59 PM
  4. VBA to Unprotect (w/ password), Unhide, Hide, and Protect (w/ password)
    By pger34 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-14-2012, 12:35 PM
  5. Help! My macro won't automatically start when I open Excel.
    By john928 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2005, 06:55 AM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1