Locking a sheet from being deleteable!

  • Thread starter Thread starter Hamidam
  • Start date Start date
H

Hamidam

Well, I guess the title says it all... Locking a sheet from being
deleteable!???

Thanks / Jennifer
 
Tools|protect|protect workbook
(Protect the structure)

No sheet will be able to be moved/deleted/inserted/renamed
 
Well, now the option of renaming the sheet disappears... they ar
supposed to represent company name... hmm...

Jennife
 
Yep.

That's why I included this warning:

No sheet will be able to be moved/deleted/inserted/renamed

Maybe you can provide a macro that would unprotect the workbook, rename the
activesheet, and then reprotect the workbook.

Something like:

Option Explicit
Sub testme01()

Dim myResp As String
Dim PWD As String
Dim myErrorNumber As Long

PWD = "passwordhere"

myResp = InputBox(Prompt:="Please enter new name for: " & vbLf & _
ActiveSheet.Name)

If Trim(myResp) = "" Then
Exit Sub
End If

ActiveWorkbook.Unprotect Password:=PWD

On Error Resume Next
ActiveSheet.Name = myResp
myErrorNumber = Err.Number
Err.Clear
On Error GoTo 0

ActiveWorkbook.Protect Structure:=True, Windows:=False, Password:=PWD

If myErrorNumber <> 0 Then
MsgBox "Invalid name, please try again!"
End If

End Sub
 
Oooh thanks again Dave... her is a snapshot of the final result now tha
Iam finished and since you have been with me from the beginning!

Thanks / Jennife

+-------------------------------------------------------------------
|Filename: Snapshot.GIF
|Download: http://www.excelforum.com/attachment.php?postid=5159
+-------------------------------------------------------------------
 
I'm one (of many) who don't connect through excelforum. So I can't see the
picture. But I'm glad you got it working.
 

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

Back
Top