I keep getting run-time error when I run the following code
Public Sub CopyRows()
Sheets("Sheet1").Select
' Find the last row of data
FinalRow = Range("A65536").End(xlUp).Row
' Loop through each row
For x = 2 To FinalRow
' Decide if to copy based on column H
ThisValue = Range("H" & x).Value
If ThisValue = "ir" Then
Range("A" & x & ":AG" & x).Copy
Sheets("a").Select
NextRow = Range("A65536").End(xlUp).Row + 1
Range("A" & NextRow).Select
ActiveSheet.Paste
Sheets("a").Select
ElseIf ThisValue = "RR" Then
MsgBox "Hello"
End If
Next x
End Sub
What am I doing wrong. Pls help. Very fustrated
Public Sub CopyRows()
Sheets("Sheet1").Select
' Find the last row of data
FinalRow = Range("A65536").End(xlUp).Row
' Loop through each row
For x = 2 To FinalRow
' Decide if to copy based on column H
ThisValue = Range("H" & x).Value
If ThisValue = "ir" Then
Range("A" & x & ":AG" & x).Copy
Sheets("a").Select
NextRow = Range("A65536").End(xlUp).Row + 1
Range("A" & NextRow).Select
ActiveSheet.Paste
Sheets("a").Select
ElseIf ThisValue = "RR" Then
MsgBox "Hello"
End If
Next x
End Sub
What am I doing wrong. Pls help. Very fustrated