I'm using the below VBA to return information from 2000's rows of data and I keep getting an error when using the line finalrow = Cells(Rows.Count, 1).End(x1Up).Row. Any help would be appreciated!
Sub finddata()
Dim datasheet As Worksheet
Dim reportsheet As Worksheet
Dim agentname As String
Dim finalrow As Integer
Dim i As Integer
Set datasheet = Sheet2
Set reportsheet = Sheet1
agentname = reportsheet.Range("C1").Value
reportsheet.Range("B4:W13").ClearContents
datasheet.Select
finalrow = Cells(Rows.Count, 1).End(x1Up).Row
For i = 2 To finalrow
If Cells(i, 1) = agentname Then
Range(Cells(i, 3), Cells(i, 24)).Copy
reportsheet.Select
Range("B100").End(x1Up).Offset(1, 0).PasteSpecial x1PasteFormulasAndNumberFormats
datasheet.Select
End If
Next I
reportsheet.Select
Range("C1").Select
End Sub
Sub finddata()
Dim datasheet As Worksheet
Dim reportsheet As Worksheet
Dim agentname As String
Dim finalrow As Integer
Dim i As Integer
Set datasheet = Sheet2
Set reportsheet = Sheet1
agentname = reportsheet.Range("C1").Value
reportsheet.Range("B4:W13").ClearContents
datasheet.Select
finalrow = Cells(Rows.Count, 1).End(x1Up).Row
For i = 2 To finalrow
If Cells(i, 1) = agentname Then
Range(Cells(i, 3), Cells(i, 24)).Copy
reportsheet.Select
Range("B100").End(x1Up).Offset(1, 0).PasteSpecial x1PasteFormulasAndNumberFormats
datasheet.Select
End If
Next I
reportsheet.Select
Range("C1").Select
End Sub