MonkeyDeath
Board Regular
- Joined
- Jul 19, 2007
- Messages
- 62
Right ive got this code
and it works fine when running it manually
ive created a command button with the design tool in VB editor,
i copied and pasted this in to the buttons VB script
when it gets to
its stopps and comes up with error 1004 Select meathod of range class failed
then when i click on the manual way to run it ot dosnt stop me from clicking on the cells i want protected but it stops me from editing them,
any ideas
Code:
ActiveWindow.SmallScroll Down:=-9
Range("A20:AG27").Select
ActiveSheet.Unprotect Password:="wyg"
Range("A1:AG60").Select
Selection.Locked = True
Selection.FormulaHidden = False
Range( _
"U57:AG60,K59:R59,K57:R57,C53:F53,C51:F51,C49:F49,C47:F47,C45:F45,J45:AA46,J47:AA48,J49:AA50,J51:AA52,J53:AA54,AD45:AF45,AD47:AF47,AD49:AF49,AD51:AF51,AD53:AF53,A36:AG40,G41:J41,A28:AG35,A20:AG27,AB16:AF16,AB14:AF14" _
).Select
Range("AB14").Activate
Selection.Locked = False
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:= _
False
Range("A20:AG27").Select
Sheets("Job (1)").Select
Sheets("Job (1)").Copy Before:=Sheets(1)
ActiveSheet.Unprotect Password:="wyg"
Range("A1:AG60").Select
Selection.Locked = True
Selection.FormulaHidden = False
Union(Range( _
"F12:S12,F10:S10,F8:S8,F6:S6,H4:K4,F2,G2,H2,I2,S2:U2,S3:U3,S4:U4,U57:AG60,K59:R59,K57:R57,C53:F53,C51:F51,C49:F49,C47:F47,C45:F45,J45:AA46,J47:AA48,J49:AA50,J51:AA52,J53:AA54,AD45:AF45,AD47:AF47,AD49:AF49,AD51:AF51,AD53:AF53,A36:AG40,G41:J41" _
), Range( _
"A28:AG35,A20:AG27,U19:W19,Z19:AB19,AB16:AF16,AB14:AF14,AB12:AF12,AB10:AF10,K16:P16,S16:T16,D16:E16,F14:S14" _
)).Select
Range("S4").Activate
Selection.ClearContents
Selection.Locked = False
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:= _
False
Range("H4:K4").Select
ActiveWorkbook.Save
and it works fine when running it manually
ive created a command button with the design tool in VB editor,
i copied and pasted this in to the buttons VB script
when it gets to
Code:
Range("A1:AG60").Select
its stopps and comes up with error 1004 Select meathod of range class failed
then when i click on the manual way to run it ot dosnt stop me from clicking on the cells i want protected but it stops me from editing them,
any ideas