2004. július 15., csütörtök

How to search an Excel worksheet for cells with a particular value


Problem/Question/Abstract:

How to search an Excel worksheet for cells with a particular value

Answer:

If WS is your worksheet:

{ ... }
var
  Rnge: OleVariant;
  { ... }

Rnge := WS.Cells;
Rnge := Rnge.Find('Is this text on the sheet?');
if Pointer(IDispatch(Rnge)) <> nil then
  {The text was found somewhere, so colour it pink}
  Rnge.Interior.Color := clFuchsia;

Nincsenek megjegyzések:

Megjegyzés küldése