With the current code you have you don’t even need to use a counter. Instead you can load FoundAt
into an array and then use the Ubound
to get the total count. Note you have to add 1 since the array is 0 based.
Add these lines before your final Msgbox
Dim iCount() as String
iCount = Split(FoundAt,", ")
MsgBox "The Search String has been found " & UBound(iCount)+1 & " times at these locations: " & FoundAt
0
solved I’m trying to add a count to the number of searches found in my code