I am trying to search a colum for a number if the text is not there i want it to search for the next peace of number. The problem is that this number may or may not be on the source worksheet that it is searching if it not there i want it to skip it if it is there i want it to do the comands. Right now i get the error 91. Here is the code i have please help understand where i went wrong.
'1227
Windows("cont 10-02 run on 10-03-06.xls").Activate
Columns("A:A").Select
If Selection.Find(What:="1227", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate Then
ActiveCell.Offset(1, 1).Range("A1").Select
Selection.Copy
Windows("WE mm-dd-yy Contractor payroll 2006 b Template.xls").Activate
Range("K12").Select
ActiveSheet.Paste
Windows("cont 10-02 run on 10-03-06.xls").Activate
Cells.Find(What:="Shift Duration:", After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(-1, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("WE mm-dd-yy Contractor payroll 2006 b Template.xls").Activate
Range("M12").Select
ActiveSheet.Paste
End If
'1231
Windows("cont 10-02 run on 10-03-06.xls").Activate
Columns("A:A").Select
If Selection.Find(What:="1231", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate Then
ActiveCell.Offset(1, 1).Range("A1").Select
Selection.Copy
Windows("WE mm-dd-yy Contractor payroll 2006 b Template.xls").Activate
Range("K13").Select
ActiveSheet.Paste
Windows("cont 10-02 run on 10-03-06.xls").Activate
Cells.Find(What:="Shift Duration:", After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(-1, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("WE mm-dd-yy Contractor payroll 2006 b Template.xls").Activate
Range("M13").Select
ActiveSheet.Paste
End If
'1227
Windows("cont 10-02 run on 10-03-06.xls").Activate
Columns("A:A").Select
If Selection.Find(What:="1227", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate Then
ActiveCell.Offset(1, 1).Range("A1").Select
Selection.Copy
Windows("WE mm-dd-yy Contractor payroll 2006 b Template.xls").Activate
Range("K12").Select
ActiveSheet.Paste
Windows("cont 10-02 run on 10-03-06.xls").Activate
Cells.Find(What:="Shift Duration:", After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(-1, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("WE mm-dd-yy Contractor payroll 2006 b Template.xls").Activate
Range("M12").Select
ActiveSheet.Paste
End If
'1231
Windows("cont 10-02 run on 10-03-06.xls").Activate
Columns("A:A").Select
If Selection.Find(What:="1231", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate Then
ActiveCell.Offset(1, 1).Range("A1").Select
Selection.Copy
Windows("WE mm-dd-yy Contractor payroll 2006 b Template.xls").Activate
Range("K13").Select
ActiveSheet.Paste
Windows("cont 10-02 run on 10-03-06.xls").Activate
Cells.Find(What:="Shift Duration:", After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(-1, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("WE mm-dd-yy Contractor payroll 2006 b Template.xls").Activate
Range("M13").Select
ActiveSheet.Paste
End If