Hi I am new learning vba trying to automate my reports at my job. In this case I'm trying to first make a simple code and learn with static range and after adding other functions in this case use a if conditional with like and * operator use a value and a range with a loop comparing the text inside the cells, my code is below and when i run the code the message box tell me the cells are not like my "a" value and only yes when the cell content is exact (a2 cell=f2 cell). Can't understand if I forget about something or my code is bad writing. Thank you very much in advance
VBA Code:
Sub test4()
Dim codeos As Range, a As String, cell As Range
a = [a2].Value
Set codeos = Range("f2:f5")
For Each cell In codeos
If a Like "*" & cell & "*" Then
MsgBox "Yes"
Else
MsgBox "No"
End If
Next cell
End Sub