This may be a duplicate question, but really don t know how else to word the title.
Has anyone been able to find a method in the Excel Interop Library that exposes the "Find All" functionality from the "Find and Replace" dialog?
There is Find, FindNext and FindPrevious, but no FindAll, which is odd.
So far, this is the way I m doing it, my first stab at it, so to speak...
//FindRange() is an extension method which wraps Worksheet.Cells.Find()
Range start = sheet.FindRange(searchText,
XlLookAt.xlPart,
XlSearchOrder.xlByColumns,
XlSearchDirection.xlNext);
HashSet<int> matches = new HashSet<int>();
Range next = start;
while (true)
{
next = sheet.Cells.FindNext(next.get_Offset(1, 0));
if (!matches.Add(next.Row))
break;
}
Any thoughts?