Dear All,
I have the following code (see below) that prompts the user for a Text string, then it searches for this string in Sheet1/ColA, and then moves that cell to Sheet2.
The problem is that I would like to move the whole row where the matched cell is contained, not only the cell itself.
How would you ammend the code to do that ?
Any help would be appreciated.
Thanks.
I have the following code (see below) that prompts the user for a Text string, then it searches for this string in Sheet1/ColA, and then moves that cell to Sheet2.
The problem is that I would like to move the whole row where the matched cell is contained, not only the cell itself.
How would you ammend the code to do that ?
Any help would be appreciated.
Thanks.
Code:
Dim myString As String
Dim foundCell As Variant
myString = Trim(UserForm2.TextBox1.Value)
If myString = vbNullString Then
Exit Sub
End If
On Error GoTo ErrorOut
With ThisWorkbook.Sheets("Sheet1").Range("A:A")
.Find(what:=myString, After:=.Cells(1, 1), lookat:=xlWhole).Delete shift:=xlUp
End With
With ThisWorkbook.Sheets("Sheet2")
.Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Value = myString
End With