Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
JennyJeneralGraves
 
Posts: n/a
Default Using VB to password protect, but sheet remains visible

I used the following code to cause a password prompt to display upon clicking
on a tab in my workbook:

Private Sub Worksheet_Activate()
Dim strPassword As String
On Error Resume Next
Me.Protect Password:="123"
Me.Columns.Hidden = True

strPassword = InputBox("Enter password to view this sheet:")

If strPassword = "" Then
Me.Previous.Select
Exit Sub
ElseIf strPassword < "datagility" Then
MsgBox "Password Incorrect", , "Wrong password"
Me.Previous.Select
Exit Sub
Else
Me.Unprotect Password:="123"
Me.Columns.Hidden = True
End If
On Error GoTo 0
End Sub

Private Sub Worksheet_Deactivate()
On Error Resume Next
Me.Columns.Hidden = True
On Error GoTo 0
End Sub

**Problem is: when I click on the tab, the sheet is displayed in the
background behind the prompt. How can I make it so that it doesn't display at
all until the password is successfully entered?
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password Protect Dedrie Excel Worksheet Functions 0 August 19th 05 07:03 PM
Password Protecting Nick Excel Discussion (Misc queries) 6 June 30th 05 12:06 PM
Sheet Protecting password Nick Excel Discussion (Misc queries) 1 June 30th 05 12:43 AM
password protect .csv file Jennifer Boe Excel Discussion (Misc queries) 1 June 1st 05 05:16 PM
when I protect my sheet enter tab, & arrow keys dont work... greg Excel Discussion (Misc queries) 0 May 25th 05 03:30 PM


All times are GMT +1. The time now is 12:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"