LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Rob Rob is offline
external usenet poster
 
Posts: 718
Default password protect workbook

Very new to VB. Have managed to paste this code into a workbook:

Option Explicit

Private Sub Workbook_Open()
Worksheets("Sheet1").Activate
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Dim ans
Dim sh2 As Worksheet
Application.EnableEvents = False
If ActiveSheet.Name < "Sheet1" Then
Set sh2 = ActiveSheet
Sh.Activate
Application.ScreenUpdating = False
ans = Application.InputBox("Supply password")
If ans < False Then
If ans = "password" Then
sh2.Activate
End If
End If
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

It works great, but would like to modify it so that I only need to enter the
password once to gain access to all worksheets, not each time I change
worksheets.

Much appreciated,
rob

 
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
Using VB to password protect, but sheet remains visible JennyJeneralGraves Excel Discussion (Misc queries) 0 March 30th 06 02:12 AM
Password Required to View\edit a Sheet in a Workbook with Many She Ed Excel Discussion (Misc queries) 1 March 27th 06 09:31 PM
Protect Workbook vs Worksheet?? Dan B Excel Worksheet Functions 3 November 7th 05 09:02 PM
Protect Workbook Daniel Excel Discussion (Misc queries) 3 October 12th 05 08:27 PM
Forgot My Workbook Password Kassie Excel Discussion (Misc queries) 0 April 10th 05 06:11 PM


All times are GMT +1. The time now is 08:03 AM.

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"