help with protection of sheets

D

des-sa

please help
i have a petty cash workbook file where there is a new sheet generated via a
macro for each day. the new sheet is generated by copying today's sheet and
clearing the contents for the new day. the date is entered into this new
sheet in cell E1, which then automatically becomes the sheet name of the new
one. is it possible to create vb code to automatically lock yesterday's
sheet for editing and hide it, so that at any point the financial person sees
only today's sheet - if so, could someone help with the code
 
S

StumpedAgain

The following macro will protect the sheet after the sheet you have currently
selected and then hide it. Depending on where you put this in your current
macro, you may want to take out the ".Next" in the macro. Also, if you want
a password, you can add "Password:=abc123" after "Scenarios:=True. Hope this
helps!

Sub ProtectAndHide()

ActiveSheet.Next.Protect Scenarios:=True
ActiveSheet.Next.Visible = False

End Sub
 
D

des-sa

Sub locksheet()
'
' locksheet Macro
' Macro recorded 2008/07/17 by DISRI
'
' Keyboard Shortcut: Ctrl+l
'
Sheets("MASTER").Select
Sheets("MASTER").Copy Before:=Sheets(3)
Range("E1").Select
ActiveCell.FormulaR1C1 = "ENTER DATE"
Range("E2").Select
Sheets("MASTER").Select
Range("M6").Select
Selection.Copy
Sheets("ENTER DATE").Select
Range("M3").Select
ActiveSheet.Paste
Range("B3:K17").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("B21:M35").Select
Selection.ClearContents
Range("E1").Select
Sheets("MASTER").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlNoSelection
Sheets("ENTER DATE").Select
Range("E1").Select
End Sub
 

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