I'm trying to create a tool wherein emails were extracted under sheet 1 and account numbers are in sheet 2.
I wanted the tool to find the account number in sheet 1 and check if there's a word "contract" and it will result to True.
The problem is that the account number can have multiple results and it only gets the first result.
For example : ACCOUNT #123 is showing in A1 that have no word "contract" on it. ACCOUNG #123 is also showing in A15 that have the word "contract"
The code will not show True because it got the ACCOUNT#123 under A1
Option Explicit
Sub FindCLG()
Dim wsI As Worksheet, ws0 As Worksheet
Dim lRow As Long, i As Long
Dim x As Long
Dim aCell As Range, bCell As Range
Dim cellad As String
Set wsI = ThisWorkbook.Sheets("Sheet1")
Set ws0 = ThisWorkbook.Sheets("Sheet3")
ws0.Range("E:F").ClearContents
lRow = ws0.Range("B" & ws0.Rows.Count).End(xlUp).Row
For i = 2 To lRow
Set aCell = wsI.Range("A:A").Find(what:=ws0.Range("b" & i).Value, LookIn:=xlValues, lookat:=xlPart, Searchorder:=xlByRows)
If Not aCell Is Nothing Then
ws0.Range("E" & i).Value = "True"
Set bCell = aCell.Offset(0, 3).Find(what:="*ontrac*", LookIn:=xlValues, lookat:=xlPart, Searchdirection:=xlNext, Searchorder:=xlByRows)
If Not bCell Is Nothing Then
ws0.Range("F" & i).Value = "True"
End If
End If
Next i
End Sub