Does anyone have any advise on searching a range (Worksheet Column) for all instances of a particular string ?
Using VBA
Thanks.
Does anyone have any advise on searching a range (Worksheet Column) for all instances of a particular string ?
Using VBA
Thanks.
I would use the Find method of the range, in a loop.
But what form do you want your results to take? Do you want a list on a worksheet? A message box? Highlight the instances?
More detailed questions get more detailed answers.
Hi Jeff. the results are destined for a listview control. It's getting them I'm looking for. If a loop is the answer I could use a For Next on each row and if the value matches
add that to the listview. But what is the best method for looping? Set a Range first or can you use a Select query?
Are you looking for an exact match of the string as the entire cell contents? Or looking for a particular string as any part of cell contents?
Looking for
"TEST"
Is this a match?
"THIS IS A TEST"
Here is the concept. This looks in column A for exact matches of the entire cell (above example would not be a match)
Please Login or Register to view this content.
OK, thanks for that. It is a partial match with wildcards. I should be able to sort that.If searching many colums is it best to
include them in the range, or do each one individually?
Make Range("A:A") whatever your actual range is. OK to make it multiple columns.
You can use Find for partial matches.
Please Login or Register to view this content.
Must the range be consecutive? You can't have e.g. Col B and Col F
The range does not need to be contiguous. You can define any set of cells as a range:
Please Login or Register to view this content.
Understood.. ideal. Thanks again
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks