Sub trouvertoto()
Dim TableauAdresses
TableauAdresses = cellsSearch(Range("A1:F20"), "toto", 0)
MsgBox UBound(TableauAdresses) & " cellules trouvée(s)"
MsgBox Join(TableauAdresses)
End Sub
'position = 0 = xlPart
'position = 1 = commence par
'position = 2 = termine par
Function cellsSearch(rng As Range, expression As String, Optional position As Long = 0)
Dim T(), Q&, cel
For Each cel In rng.Cells
Select Case position
Case 0: finding = InStr(cel.Value, expression) > 0
Case 1: finding = Left(cel.Value, Len(expression)) = expression
Case 2: finding = Right(cel.Value, Len(expression)) = expression
End Select
If finding = True Then Q = Q + 1: ReDim Preserve T(1 To Q): T(Q) = cel.Address
finding = False
Next
If Q = 0 Then cellsSearch = Array(0) Else cellsSearch = T
End Function