Getting Excel find function to work

Add-in Express™ Support Service
That's what is more important than anything else

Getting Excel find function to work
Looking for help to get ExcelRange Find function working. 
samhow


Guest


Hi,

I am looking for some help getting the Excel ExcelRange.find function to work.

I want to search a column for a value and get the row number of the first cell that contains
the value.

Currently my code looks like this :

fndRng := wrkSheet.cells.Find(val,wrkSheet.Cells.item[1,col], xlValues,
emptyParam, emptyParam, emptyParam, true, false);

Currently it returns the error message : Could not convert type variant to type boolean.

I am doing this in the hope that the Excel find function will be faster than looping through the rows myself in delphi and looking for the value.

All suggestions appreciated.

Thanks
Sam
Posted 07 Oct, 2010 12:16:22 Top
samhow


Guest


I managed to get a search of a single column working with this code :

tstRng := wrkSheet.Range[wrkSheet.Cells._Default[1, col],
wrkSheet.Cells._Default[
X wrkSheet.UsedRange[adxLCID].Rows.Count, col]]
.Find(
val, wrkSheet.Cells.Item[1,col], xlValues, xlWhole, xlByRows, xlPrevious,
X false, false);
if assigned(tstRng) = false then begin
// not found
end else begin
// found on the row : tstRng.row;

end;
Posted 07 Oct, 2010 14:43:14 Top
Eugene Astafiev


Guest


Hi Sam,

Thank you for sharing the solution for others. Good luck with your add-in project!
Posted 12 Oct, 2010 12:32:55 Top