Are you using Excel 97? If so, you need to change the
SetFocusOnClick property of the command button to FALSE.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Oldjay" wrote in message
...
I can run the following code from the command button but get
"Runtime error "1004"
Application-defined or object-defined error" when I try to step
thru it in
VBA at Range("J2").Select
Private Sub CommandButton1_Click() 'Print or view birthday list
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'
Dim Birthdate As String
Birthdate = Range("Form!M15")
Sheets("Records").Select
Range("J2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=10, Criteria1:=Birthdate,
Operator:=xlAnd
Selection.Sort Key1:=Range("J3"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Range("B2:L2").Select ' Selects all filtered data
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy 'Copies filtered job data
Sheets("Birthday").Select
Range("A2").Select
ActiveSheet.Paste 'Pastes Values
Range("A1:K2").Select ' Selects all filtered data
Range(Selection, Selection.End(xlDown)).Select
'Selection.Copy 'Copies filtered job
Selection.PrintOut Copies:=1, Preview:=True, Collate:=True
Range("A2:K2").Select ' Selects all filtered data
Range(Selection, Selection.End(xlDown)).Select
Selection.Clear
Sheets("Records").Select
Selection.AutoFilter
Sheets("Form").Select ' Goes to date input screen
Range("A47").Select
Range("C47").Select
End SubI have the following code