This code works perfectly every time. But the value of x must match EXACTLY the contents of the cell value

This code will find all cells which contain ONLY "pymt" and copy them to reportsheet.

Great.

BUT what if the value of x is CONTAINED WITHIN a cell with other text before and after x ?

Is there a way to use wildcard or pattern searches with x suchas **x** etc. so that the code will pick up all values of x whether

at the beginning, in the middle or at the end of any text in a cell ? I prefer to use an if then statement

if possible.

Please help on this. Will be very much appreciated.

THanks,

cr

Code:

```
Sub SEARCHANDCOPY()
Dim datasheet As Worksheet
Dim reportsheet As Worksheet
Dim x As String
Dim finalrow As Integer
Dim i As Integer
Set datasheet = Worksheets("Sheet1")
Set reportsheet = Worksheets("Sheet2")
x = reportsheet.Range("H1").value
reportsheet.Range("A5:G200").ClearContents
datasheet.Select
finalrow = Cells(Rows.count, 1).End(xlUp).Row
For i = 2 To finalrow
If Cells(i, 4) = x Then
Range(Cells(i, 1), Cells(i, 9)).copy
reportsheet.Select
Range("A200").End(xlUp).Offset(1, 0).PasteSpecial xlPasteFormulasAndNumberFormats
datasheet.Select
End If
Next i
reportsheet.Select
Range("H1").Select
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
```

Great.

BUT what if the value of x is CONTAINED WITHIN a cell with other text before and after x ?

Is there a way to use wildcard or pattern searches with x suchas **x** etc. so that the code will pick up all values of x whether

at the beginning, in the middle or at the end of any text in a cell ? I prefer to use an if then statement

if possible.

Please help on this. Will be very much appreciated.

THanks,

cr