Check whether text in cell2 is contained in cell1, equivalent to =SUBSTITUTE(A1,B1,"")<>A1

Function HasText(cell1 As Range, cell2 As Range) As Boolean
 If Application.WorksheetFunction.Substitute(cell1, cell2, "") <> cell1 Then HasText = True
End Function

or

Function HasText2(cell1 As Range, cell2 As Range) As Boolean
 HasText2 = cell1 Like "*" & cell2 & "*"
End Function


© Copyright andrewsexceltips.net All Rights Reserved.