I am trying to have a search by cell value I dont know if the code I have is my best choice. and Im having errors with it, I want to search a cell value from another sheet "Family Ref" in same work book , and when find is done, to copy all rows that include this value and paste is on "view" sheet on a cell/rows range that I choose which always will be same.
with this code the error im having is :select method of range class failed.
any help on my code or suggestion other than my code would appreciate it.
Sub select_rows_with_given_string()
Dim Rng As Range
Dim myCell As Object
Dim myUnion As Range
setmycell = Sheets("view").Range("A2")
Set Rng = Selection
Sheets("Family Ref").Select
Columns("A:M").Select
For Each myCell In Rng
If InStr(myCell.Text, searchString) Then
If Not myUnion Is Nothing Then
Set myUnion = Union(myUnion, myCell.EntireRow)
Else
Set myUnion = myCell.EntireRow
End If
End If
Next
If myUnion Is Nothing Then
MsgBox "No Registration Found."
Else
myUnion.Select
Sheets("view").Select
Selection.Copy
Range("A5").Select
ActiveSheet.Paste
End If
End Sub