Hi try this
I've named the sheet that you want to Copy as "Master" added a Button "Admin"
Added a New Sheet called Admin and added two buttons and assigned Macros to them
Button1. Amend "Master" Sheet password "lemonade"
Button2. Amend "Fields" Sheet password "lemonade
In the VBA editor, find the "ThisWorkbook" object and dbl click. You will get a window titled "bookName - ThisWorkbook". In the left dropdown select workbook and you should get a workbook open event procedure.
Try this and see if it does what you want.
Private Sub Workbook_Open()
Dim sht As Worksheet
Dim shtName As String
Dim aDate As Date
aDate = Int(Now())
aDate = aDate - (Weekday(aDate, vbMonday) - 1)
Application.ScreenUpdating = False
Call UnProtect("thescientist")
shtName = Format(aDate, "dd-mm-yyyy")
On Error Resume Next
Set sht = Sheets(shtName)
On Error GoTo 0
Application.ScreenUpdating = True
If (sht Is Nothing) Then
Application.ScreenUpdating = False
Sheets("Master").Copy After:=Sheets(Sheets.Count)
Sheets("Master").Visible = False
Sheets("Fields").Visible = False
Sheets("Admin").Visible = True
Sheets("Master (2)").Visible = True
Sheets("Master (2)").Select
Sheets("Master (2)").Name = shtName
Application.ScreenUpdating = True
End If
Call Protect("thescientist")
End Sub
I also added to Modules in the VBA
Module1
Option Explicit
Sub Protect(myPassword As String)
ActiveWorkbook.ActiveSheet.Protect Password:="thescientist"
ActiveWorkbook.Protect Password:=myPassword
End Sub
Sub UnProtect(myPassword As String)
ActiveWorkbook.ActiveSheet.UnProtect Password:="thescientist"
ActiveWorkbook.UnProtect Password:=myPassword
End Sub
Module2
Sub unHidesh()
Call UnProtect("thescientist")
Application.ScreenUpdating = False
Dim MyValue As Variant
MyValue = InputBox("Please Enter Your Password")
If MyValue = "lemonade" Then 'lemonade being the password
Sheets("Admin").Visible = True
Sheets("Admin").Activate
Else
MsgBox ("Password Incorrect")
End If
Application.ScreenUpdating = True
Call Protect("thescientist")
End Sub
Sub unHidesh1()
Call UnProtect("thescientist")
Application.ScreenUpdating = False
Dim MyValue As Variant
MyValue = InputBox("Please Enter Your Password")
If MyValue = "lemonade" Then 'lemonade being the password
Sheets("Master").Visible = True
Sheets("Master").Activate
Else
MsgBox ("Password Incorrect")
End If
Application.ScreenUpdating = True
Call Protect("thescientist")
End Sub
Sub unHidesh2()
Call UnProtect("thescientist")
Application.ScreenUpdating = False
Dim MyValue As Variant
MyValue = InputBox("Please Enter Your Password")
If MyValue = "lemonade" Then 'lemonade being the password
Sheets("Fields").Visible = True
Sheets("Fields").Activate
Else
MsgBox ("Password Incorrect")
End If
Application.ScreenUpdating = True
Call Protect("thescientist")
End Sub
Sub Hidesh()
Call UnProtect("thescientist")
Application.ScreenUpdating = False
Sheets("Master").Visible = False
Application.ScreenUpdating = True
Call Protect("thescientist")
End Sub
Bookmarks