So I'm running the following code attempting to locate certain lines from one sheet and copy them to another sheet. It worked fine when I used "selection.copy", but when I changed it to "selection.cut" it would only work for a little bit before I got "run time error 1004 - paste method of worksheet class failed". Now here is the part that really confuses me. If I end the macro at the error and then run it again, it slowly gets farther into the macro. So if it failed at line 200 the first time I ran it, by now it's failing at line 1000. The only thing I can think is that maybe I'm overloading some sort of memory. Not sure, I'm wondering if anyone else has had this happen and/or knows the reason/solution. Thanks
My macro code:
Sub finddata()
'
' finddata Macro
'
' Keyboard Shortcut: Ctrl+Shift+F
'
Dim ordernumber As String
Dim cellcounter As Integer
cellcounter = 0
For irow = 1 To 1600
cellcounter = 0
Sheets("T Inspections Query").Activate
Range("E" & irow).Select
ordernumber = ActiveCell.Value
Range(Cells(irow, 2), Cells(irow, 15)).Select
Selection.Cut
Sheets("Sheet1").Activate
Range("B1:B8490").Select
For Each cell In Selection
cellcounter = cellcounter + 1
If ordernumber <> "" And InStr(1, cell, ordernumber, vbBinaryCompare) Then
Range("T" & cellcounter).Select
ActiveSheet.Paste
Else
End If
Next
Next
End Sub
Bookmarks