I'm trying to do a simple search macro that displays results but keep getting an error on 1 line of the code.
Sub search()
'declare variables
Dim name As String
Dim finalrow As Integer
'r meaning row
Dim r As Integer
'clear old search results
Range("k21:w30").ClearContents
'Sets the customers name that was entered into k20 as Name
name = Sheets("Customer Search").Range("k20").Value
' Customer list starts in column G
'sets the final row to stop searching
finalrow = Sheets("customer info").Range("g2").End(x1down).row
'searches from row 2 to final row
For r = 2 To finalrow
'if the row it's in, column 7 (which would be g)lists the name then it copies and pastes that row from column g to column s.
If Cells(r, 7) = name Then
Sheets("customer info").Range(Cells(r, 7), Cells(r, 19)).Copy
Sheets("Customer Search").Range("k50").End(x1up).Offset(1, 0).rowPasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.ScreenUpdating = False
End If
Next r
End Sub
I keep getting an error on
finalrow = Sheets("customer info").Range("g2").End(x1down).row
Sub search()
'declare variables
Dim name As String
Dim finalrow As Integer
'r meaning row
Dim r As Integer
'clear old search results
Range("k21:w30").ClearContents
'Sets the customers name that was entered into k20 as Name
name = Sheets("Customer Search").Range("k20").Value
' Customer list starts in column G
'sets the final row to stop searching
finalrow = Sheets("customer info").Range("g2").End(x1down).row
'searches from row 2 to final row
For r = 2 To finalrow
'if the row it's in, column 7 (which would be g)lists the name then it copies and pastes that row from column g to column s.
If Cells(r, 7) = name Then
Sheets("customer info").Range(Cells(r, 7), Cells(r, 19)).Copy
Sheets("Customer Search").Range("k50").End(x1up).Offset(1, 0).rowPasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.ScreenUpdating = False
End If
Next r
End Sub
I keep getting an error on
finalrow = Sheets("customer info").Range("g2").End(x1down).row