protect with password

N

nowfal

hi,
the following code starts with unprote the sheet and end with protected
sheet, now the problem is anybody can unprotect the sheet and do
something in the sheet . to avoid that i wanted to protect the sheet
with my own password say 'nowfal'. Is it possible to do that . if so
please help me in this matter .


Sub FCY2()
'
' FCY2 Macro
' Macro recorded 15/07/2004 by Musandam
'

'
ActiveSheet.Unprotect
Sheets("BILL").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("RECORD").Select
Range("A2:AH12000").Select
Selection.Copy
Range("A3").Select
ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False,
_
IconFileName:=False
Range("C2:H2").Select
Selection.ClearContents
Range("J2:L2").Select
Selection.ClearContents
Range("N2").Select
Selection.ClearContents
ActiveWindow.SmallScroll ToRight:=6
Range("O2:R2").Select
Selection.ClearContents
Range("T2:W2").Select
Selection.ClearContents
Range("Y2:AB2").Select
Selection.ClearContents
Range("AD2:AG2").Select
Selection.ClearContents
ActiveWindow.ScrollColumn = 1
Range("D2").Select
ActiveSheet.Protect DrawingObjects:=True, Scenarios:=True
ActiveWorkbook.Save
End Sub
 
L

Losse

Sub ProtectSheet()
Dim Password
Password = "nowfal"
ActiveSheet.Protect Password, True, True, True
End Sub
Sub UnProtectSheet()
Password = "nowfal"
ActiveSheet.Unprotect Password
End Sub
 
N

nowfal

HI,
Sorry its not working, i repeat and shorten the code

ActiveSheet.Unprotect

ActiveSheet.Protect DrawingObjects:=True, Scenarios:=True
ActiveWorkbook.Save
End Sub

that unprotect with password say 'nowal'
at the end protect with same password.
eagerly waiting for the solution.
thanks in advance
with
regards
nowfa
 
D

dominicb

Good evening Nowfal

Change this line:

ActiveSheet.Protect DrawingObjects:=True, Scenarios:=True

to this:

ActiveSheet.Protect DrawingObjects:=True, Scenarios:=True,
Password:="nowfal"

Is that any better?

HTH

DominicB
 
N

nowfal

Hi,
Mr.Dominic , sorry that is not working any other solution?, earlie
Late Mr.Frank kablin had given some idea , but i couldn't follow up
after sometime that great man left the world by tragic accident. Stil
i remember his contribution to this forum.
May God bless him.
regards
nowfa
 
D

dominicb

Hi Nowfal

It does work. Copy this code in its entirity into a moduleof a blan
workbook. Run it, and then try to unprotect the sheet (Tools
Protection > Unprotect Sheet. You will be prompted for a password
the password is "nowfal", without the quotes.

Sub ProtectSheet()
ActiveSheet.Protect DrawingObjects:=True, Scenarios:=True
Password:="nowfal"
End Sub

HTH

Dominic
 
N

nowfal

hi ,
sorry to say its not working.
Still i am short of my requirement. when i am firing the macro i am
getting the unprotect box , which i am not expecting , my intention is
no other user can unprotect the sheet without my permission, and in the
mean while they and myself can able to do the normal job.
with regards
nowfal
 

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