G
Gizmo
Excel 2003
I have a Form button with the following code in a Module. I want to use a
Command button so I can change the color of the button. When I run the same
code in the command button in the worksheet module I get a "Select method of
Range Class failed" error.
What's wrong?
Private Sub CommandButton10_Click()
ActiveWorkbook.Unprotect Password:="scott"
Sheets("Records").Visible = True
Sheets("AddRecords").Visible = False
Sheets("Records").Activate
Sheets("Records").Unprotect Password:="scott"
Range("B:B,E:G,I:N,P:W").Select
Range("W1").Activate
Selection.EntireColumn.Hidden = True
Range("C5").Select
ActiveSheet.EnableAutoFilter = True
ActiveSheet.Protect contents:=True, userInterfaceOnly:=True 'Added
Descend code here
Range("A4:W505").Sort Key1:=Range("A4"), Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Sheets("Records").Protect Password:="scott"
ActiveWorkbook.Protect Password:="scott"
End Sub
I have a Form button with the following code in a Module. I want to use a
Command button so I can change the color of the button. When I run the same
code in the command button in the worksheet module I get a "Select method of
Range Class failed" error.
What's wrong?
Private Sub CommandButton10_Click()
ActiveWorkbook.Unprotect Password:="scott"
Sheets("Records").Visible = True
Sheets("AddRecords").Visible = False
Sheets("Records").Activate
Sheets("Records").Unprotect Password:="scott"
Range("B:B,E:G,I:N,P:W").Select
Range("W1").Activate
Selection.EntireColumn.Hidden = True
Range("C5").Select
ActiveSheet.EnableAutoFilter = True
ActiveSheet.Protect contents:=True, userInterfaceOnly:=True 'Added
Descend code here
Range("A4:W505").Sort Key1:=Range("A4"), Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Sheets("Records").Protect Password:="scott"
ActiveWorkbook.Protect Password:="scott"
End Sub