Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 386
Default Urgent - Simple Workbook Protect

Hi,

I am using the macro attached below to drive a series of worksheets, graphs
etc. I would like to change the protect and unrpotect sheet parts to
protect/unp the whole workbook as that will also lock the sheet tab names.

Could somebody tell me how please? When I try I get loads an error

Thanks
LiAD

Sub BobineProduit15()

Sheets("UP1 Production").Unprotect Password:="ABCDEF"
Sheets("UP4 Données").Unprotect Password:="ABCDEF"

Call AddToLog("BobineProduit15")

If myT = 0 Then myT = Now

With Sheet4
If Now - myT 1 / 1440 Then 'Note - use 1440 (60*24), not 14400
..Range("L6").Value = 0
Else
..Range("L6").Value = .Range("L6").Value + 1
End If
myT = Now
End With

'Add 1 to I38
With Sheet1
If IsNumeric(.Range("J38").Value) Then
..Range("J38").Value = .Range("J38") + 1
Else
MsgBox "J38 on sheet1 isn't a number!"
End If
End With
Sheets("UP1 Production").Protect Password:="ABCDEF"
Sheets("UP4 Données").Protect Password:="ABCDEF"
End Sub



Sub AddToLog(MacName As String)

Sheets("Log").Unprotect Password:="ABCDEF"

Dim NextRow As Long

With Worksheets("Log")
NextRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
.Cells(NextRow, "A").Value = MacName
.Cells(NextRow, "B").Value = Now
End With

Sheets("Log").Protect Password:="ABCDEF"

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Urgent - Simple Workbook Protect

You can protect and unprotect sheets with workbook protection enabled.

So just go ahead and protect the workbook once and leave protected.

If you do want to protect/unprotect add these lines before and after the
sheet protection lines.

ActiveWorkbook.Unprotect Password:="justme"
Sheets("UP1 Production").Unprotect Password:="ABCDEF"
Sheets("UP4 Données").Unprotect Password:="ABCDEF"

other code here.......................

Sheets("UP1 Production").Protect Password:="ABCDEF"
Sheets("UP4 Données").Protect Password:="ABCDEF"
ActiveWorkbook.Protect Password:="justme", Structu=True, Windows:=True


Gord Dibben MS Excel MVP

On Wed, 8 Apr 2009 06:31:01 -0700, LiAD
wrote:

Hi,

I am using the macro attached below to drive a series of worksheets, graphs
etc. I would like to change the protect and unrpotect sheet parts to
protect/unp the whole workbook as that will also lock the sheet tab names.

Could somebody tell me how please? When I try I get loads an error

Thanks
LiAD

Sub BobineProduit15()

Sheets("UP1 Production").Unprotect Password:="ABCDEF"
Sheets("UP4 Données").Unprotect Password:="ABCDEF"

Call AddToLog("BobineProduit15")

If myT = 0 Then myT = Now

With Sheet4
If Now - myT 1 / 1440 Then 'Note - use 1440 (60*24), not 14400
.Range("L6").Value = 0
Else
.Range("L6").Value = .Range("L6").Value + 1
End If
myT = Now
End With

'Add 1 to I38
With Sheet1
If IsNumeric(.Range("J38").Value) Then
.Range("J38").Value = .Range("J38") + 1
Else
MsgBox "J38 on sheet1 isn't a number!"
End If
End With
Sheets("UP1 Production").Protect Password:="ABCDEF"
Sheets("UP4 Données").Protect Password:="ABCDEF"
End Sub



Sub AddToLog(MacName As String)

Sheets("Log").Unprotect Password:="ABCDEF"

Dim NextRow As Long

With Worksheets("Log")
NextRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
.Cells(NextRow, "A").Value = MacName
.Cells(NextRow, "B").Value = Now
End With

Sheets("Log").Protect Password:="ABCDEF"

End Sub



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
Simple Question but need urgent help pls... hendnov Excel Worksheet Functions 1 July 12th 06 02:13 PM
Protect Workbook Vs Protect Sheet Poor_pakistani New Users to Excel 4 May 25th 06 02:06 PM
"Urgent" use script to share the workbook man Excel Discussion (Misc queries) 1 August 17th 05 02:09 PM
Shared Workbook Problem, Urgent calimari Excel Discussion (Misc queries) 2 July 8th 05 07:48 PM
URGENT!!! shared workbook A.G.M ash New Users to Excel 1 May 26th 05 10:14 PM


All times are GMT +1. The time now is 03:58 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"