I am new to VBA and am trying to recreate the Find All function in my Quote Worksheet to copy and paste any line in the B column (between B30 and B350) containing , CB (in the middle of the text) to copy and paste into a new worksheet (Work Order) to formulate a parts list at column AA.
Sub CreateWorkOrder()
Dim quote As Worksheet
Dim Work_Order As Worksheet
Dim CB As String
Dim finalrow As Integer
Dim i As Integer
Set quote = Sheet1
Set Work_Order = Sheet10
CB = quote.Range("B2").Value
number = "*, CB*"
'goto sheet and start searching and copying
quote.Select
finalrow = 350
'loop through the rows to find the matching records
For i = 30 To finalrow
If Cells(i, 2) = CB Then
Range(Cells(i, 1), Cells(i, 2)).Copy
Work_Order.Select
Range("AA300").End(xlUp).Offset(1, 0).PasteSpecial xlpastevalue
Range("AA" & i + 1).PasteSpecial xlPasteValues
quote.Select
End If
Next i
Work_Order.Select
Range("B21").Select
End Sub
I get a PasteSpecial method of range class failed at
Range("AA300").End(xlUp).Offset(1, 0).PasteSpecial xlpastevalue