vba help

N

nowfal

Hi,
The following vba(macro) need to protected correctly, now the sheet i
protected but not with a password. How to do that , i saw some day
early with somebody's post , but i dont remember now so please help.

Sub FCY()
'
' FCY Macro
' Macro recorded 18/05/2004 by Musandam
'

'
Range("A2").Select
ActiveSheet.Unprotect
Range("A2:K10000").Select
Selection.Copy
Range("A3").Select
ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False
_
IconFileName:=False
Range("B2:J2").Select
Selection.ClearContents
Range("L2").Select
Selection.ClearContents
Range("B2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True
ActiveWorkbook.Save
End Sub

thanks in advance,
nowfa
 
B

Bob Phillips

Sub FCY()
'
' FCY Macro
' Macro recorded 18/05/2004 by Musandam
'
ActiveSheet.Unprotect
Range("A2:K10000").Copy
Range("A3").Select
ActiveSheet.PasteSpecial Format:=3, _
Link:=1, _
DisplayAsIcon:=False, _
IconFileName:=False
Range("B2:J2").ClearContents
Range("L2").ClearContents
Range("B2").Select
ActiveSheet.Protect Password:="drowssap", _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True
ActiveWorkbook.Save
End Sub

After first time, you will need to add the password to the Unprotect as
well.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
F

Frank Kabel

Hi
change the line
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True

to
ActiveSheet.Protect Password:= "Your password", DrawingObjects:=True,
Contents:=True,
Scenarios:=True
 

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

Similar Threads


Top