I have a worksheet called Master Table with columns A-CR. The Column I am searching is in column B. In the same workbook I have a spreadsheet called SearchMasterTable I am using cell C1 in this workbook for the input of the requested lookup.
If the data in SearchMasterTable C1 equals one or multiple records in workbook Master Table column B, I am trying to copy these records to the workbook SearchMasterTable starting with row 6.
When I run it with the following code I am receiving a Run-time error '1004': Application-Defined or object-defined error.
I can't seem to figure out what I am missing, any help is much appreciated.
If the data in SearchMasterTable C1 equals one or multiple records in workbook Master Table column B, I am trying to copy these records to the workbook SearchMasterTable starting with row 6.
When I run it with the following code I am receiving a Run-time error '1004': Application-Defined or object-defined error.
I can't seem to figure out what I am missing, any help is much appreciated.
Code:
Sub finddata()
Dim ApplicationNumber As String
Dim finalrow As Integer
Dim i As Integer
Sheets("SearchMasterTable").Range("A6:CR506").ClearContents
ApplicationNumber = Sheets("SearchMasterTable").Range("C1").Value
finalrow = Sheets("Master Table").Range("A10000").End(xlUp).Row
For i = B8 To finalrow
If Cells(i, 2) = ApplicationNumber Then
Sheets("Master Table").Range(Cells(i, 1), Cells(i, 96)).Copy
Sheets("SearchMasterTable").Range("A6").End(xlUp).Offset(1, 0).PasteSpecial xlPasteFormulasAndNumberFormats
End If
Next i
Range("C2").Select
End Sub