MhmdHalawi
New Member
- Joined
- Aug 10, 2018
- Messages
- 6
This is a search and print code, but the problem is that the code only finds results that are 100% like the searched for name or text, can this be tweaked so that it finds almost the same ? for example instead of typing Jonathan i can type Jon
Code:
Sub Button1_Click()Dim lastrow As Long
Dim count As Integer
Dim n As String
lastrow = Sheet3.Cells(Rows.count, 1).End(xlUp).Row
count = 0
y = 2
a = 2
For a = 2 To lastrow
Sheet4.Cells(a, 1).ClearContents
Sheet4.Cells(a, 2).ClearContents
Sheet4.Cells(a, 3).ClearContents
Next a
n = Sheet4.Range("E1")
For x = 2 To lastrow
If Sheet3.Cells(x, 1) Like n Then
Sheet4.Cells(y, 1) = Sheet3.Cells(x, 1)
Sheet4.Cells(y, 2) = Sheet3.Cells(x, 2)
Sheet4.Cells(y, 3) = Sheet3.Cells(x, 3)
count = count + 1
y = y + 1
End If
Next x
If count = 0 Then
For y = 2 To lastrow
Sheet4.Cells(y, 1).ClearContents
Sheet4.Cells(y, 2).ClearContents
Sheet4.Cells(y, 3).ClearContents
Next y
End If
End Sub
Last edited by a moderator: