Edit macro to make it run on open


Posted by Dwight on June 13, 2001 7:06 AM

How do I edit the following macro to make it run whenever the workbook it is contained in is opened?

Thanks.
ActiveSheet.Unprotect
Range("A9").Select
ActiveWindow.SmallScroll Down:=190
Range("A9:D209").Select
Selection.Sort Key1:=Range("B9"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("B9").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios _
:=True

End Sub



Posted by Ivan F Moala on June 13, 2001 7:23 AM

You don't say which version of excel
so assuming excel97 /2000

Place this code in the ThisWorkbook object
in the Project explorer

Private Sub Workbook_Open()
ActiveSheet.Unprotect
Range("A9:D209").Select
Selection.Sort Key1:=Range("B9"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("B9").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub


HTH


Ivan