Password in Visual basic editor

T

Tia

Hi

I have a workbook for time sheet and i have used the following code so
i can be able to have the first sheet always displayed and whenever
you click on the name the concerned sheet will open
what i need now is the following:
1.what is the way that whenever you click on a name to open you will
have a password protection for each sheet so only the sheet user can
open his sheet that will be protected by a password the main sheet
should be non protected only the the other sheets and what can i do to
stop all the codes and the password so i can udjust info each month ?

2. can i put it on share even thow its protected or whenever i put it
on share no password would be prompt ?

The code that im using is the following : Workbook code
Private Sub Workbook_Open()
Dim ws As Worksheet
Sheets("Main").Select
If Range("D1").Value = "Tia" Then
For Each ws In ThisWorkbook.Worksheets
ws.Visible = True
Next ws
End If
End Sub


Sheet Main

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ws As Worksheet
Dim RngOfNames As Range
If Target.Count > 1 Then Exit Sub
If Range("D1").Value = "Tia" Then Exit Sub
Set RngOfNames = Union(Range("A12:A46"), Range("F12:F46"))
Application.ScreenUpdating = False
If Not Intersect(Target, RngOfNames) Is Nothing Then
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Main" Then ws.Visible = False
Next ws
On Error GoTo NoSht
Sheets(CStr(Target.Value)).Visible = True
Sheets(CStr(Target.Value)).Select
End If
Application.ScreenUpdating = True
Exit Sub
NoSht:
On Error GoTo 0
MsgBox "There is no sheet named " & Target.Value & ".", 16,
"Invalid Sheet Name"
End Sub




Tia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top