Hi,
I am writing a macro which can find if a cell in Column B contains the words in column A. If it does, it writes result in column C.
eg. in the following table, B3 has word 'not' so 'Found' is displayed in C3.
Goal:
<tbody>
</tbody>
I manage to write a code that does the task only if cells exactly match. eg B7 and B8.
Sub FindExistance()
Dim ws As Excel.Worksheet
Set ws = ActiveSheet 'assign active sheet to ws
Set objRange = ws.Range("A1").EntireColumn '
i = 1
Do Until ws.Cells(i, 2).Value = ""
strName = ws.Cells(i, 2).Value
Set objSearch = objRange.Find(strName)
If objSearch Is Nothing Then
ws.Cells(i, 3).Value = "Not Found"
Else
ws.Cells(i, 3).Value = "Found"
End If
i = i + 1
Loop
End Sub
I couldn't manage to get it work if only one word match the string. I tried using InStr but couldn't get it done.
Thanks in advance.
P
I am writing a macro which can find if a cell in Column B contains the words in column A. If it does, it writes result in column C.
eg. in the following table, B3 has word 'not' so 'Found' is displayed in C3.
Goal:
<tbody> </tbody> |
<tbody>
</tbody>
I manage to write a code that does the task only if cells exactly match. eg B7 and B8.
Sub FindExistance()
Dim ws As Excel.Worksheet
Set ws = ActiveSheet 'assign active sheet to ws
Set objRange = ws.Range("A1").EntireColumn '
i = 1
Do Until ws.Cells(i, 2).Value = ""
strName = ws.Cells(i, 2).Value
Set objSearch = objRange.Find(strName)
If objSearch Is Nothing Then
ws.Cells(i, 3).Value = "Not Found"
Else
ws.Cells(i, 3).Value = "Found"
End If
i = i + 1
Loop
End Sub
I couldn't manage to get it work if only one word match the string. I tried using InStr but couldn't get it done.
Thanks in advance.
P