+ Reply to Thread
Results 1 to 5 of 5

VBA code lock tab with password

  1. #1
    Forum Contributor
    Join Date
    09-30-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    266

    VBA code lock tab with password

    Hi All,

    I require a few help for an attendance chart which I'm trying to mod as attached.

    1. I need to hide the sheet 1 (Time Log) and only be able to view/edit with a password. I have this VBA code and pasted it into the worksheet but am facing a debug error. Can anybody see where I've went wrong. I've removed the code from the workbook and pasted it here.

    The password is currently set to code1



    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Dim MySheets As String, Response As String
    MySheet = "Sheet1"
    If ActiveSheet.Name = MySheet Then
    ActiveSheet.Visible = False
    Response = InputBox("Enter password to view sheet")
    If Response = "code1" Then
    Sheets(MySheet).Visible = True
    Application.EnableEvents = False
    Sheets(MySheet).Select
    Application.EnableEvents = True
    End If
    End If
    Sheets(MySheet).Visible = True
    End Sub


    2. I would like to insert a user/ date time stamp on sheet 3 (scan) in the date columns. when an input is keyed in column b (Scan in) user/ date time stamp is created.

    Any assistance will be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA code lock tab with password

    Unfortunately your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    09-30-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    266

    Re: VBA code lock tab with password

    Hi

    Thanks for the reply. Did I wrap the code correctly as per forum rules?

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: VBA code lock tab with password

    Your code was incorrect.
    I've attached a working sample.
    Attached Files Attached Files
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  5. #5
    Forum Contributor
    Join Date
    09-30-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    266

    Re: VBA code lock tab with password

    Hi Keebellah
    Thank you for the reply. Thank you for showing me the right path!! realized though that I can still unhide the tab if I right click on them. Is there any way to not enable that or create a password to block?

+ 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. Macro to Lock each row by Password
    By nandhamnk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-11-2015, 08:35 AM
  2. [SOLVED] Password lock for Worksheet in a excel workbook
    By z3162238 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-16-2014, 09:54 AM
  3. [SOLVED] Lock Rows With A Password After 5 Days
    By JeevsM in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2014, 07:08 AM
  4. Automatically Lock Sheets With Pre-Set Password
    By Eric Excels in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-31-2011, 12:16 AM
  5. Can I password Lock a sheet in a Workbook
    By ukphoenix in forum Excel Programming / VBA / Macros
    Replies: 36
    Last Post: 07-15-2008, 03:59 PM
  6. lock cells lost password
    By dcutts666 in forum Excel General
    Replies: 2
    Last Post: 04-18-2007, 07:53 AM
  7. How to lock password
    By Slade in forum Excel General
    Replies: 2
    Last Post: 05-15-2006, 02:15 PM

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