 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bruce McIver Guest
|
Posted: Fri Sep 10, 2004 3:57 pm Post subject: What cell am I in?! |
|
|
Quick question.
I'm using Delphi 7.
I open an excel file and search for a specific and unique value (e.g 1234)
in that file like so:
Excel.Selection.Find('1234', Excel.ActiveCell, xlFormulas, xlPart, xlByRows,
xlNext, False).Activate;
Upon finding that value the cell that the value is in becomes the active
cell. How do I get back to Delphi information on which cell I have actually
landed in (e.g. 'A10')?
Thanks in advance for any help.
Bruce
|
|
| Back to top |
|
 |
Mariusz Celmer Guest
|
Posted: Fri Sep 10, 2004 5:31 pm Post subject: Re: What cell am I in?! |
|
|
use Excel.ActiveCell.Address
you can also loop through all matching cells without its activating (but
still getting their address) like this:
LFirstCellAddress := ''; // as string
LRange := Lsheet.Cells.Find('1234', XLApplication.ActiveCell); // as
oleVariant
while (not VarIsClear(LRange)) and (LFirstCellAddress <> LRange.Address)
do
begin
if LFirstCellAddress = '' then LFirstCellAddress := LRange.Address;
ListBox1.Items.Add(LRange.Address);
LRange := Lsheet.Cells.FindNext(LRange); // FindNext continues searching
on criteria set up in Find function.
end;
hth,
Mariusz
"Bruce McIver" <b.mciver (AT) marlab (DOT) ac.uk> wrote
| Quote: | Quick question.
I'm using Delphi 7.
I open an excel file and search for a specific and unique value (e.g 1234)
in that file like so:
Excel.Selection.Find('1234', Excel.ActiveCell, xlFormulas, xlPart,
xlByRows,
xlNext, False).Activate;
Upon finding that value the cell that the value is in becomes the active
cell. How do I get back to Delphi information on which cell I have
actually
landed in (e.g. 'A10')?
Thanks in advance for any help.
Bruce
|
|
|
| Back to top |
|
 |
Bruce McIver Guest
|
Posted: Mon Sep 13, 2004 8:18 am Post subject: Re: What cell am I in?! |
|
|
Thanks Mariusz,
Got that working fine now.
"Mariusz Celmer" <Mariusz.Celmer (AT) poczta (DOT) neostrada.pl> wrote
| Quote: | use Excel.ActiveCell.Address
you can also loop through all matching cells without its activating (but
still getting their address) like this:
LFirstCellAddress := ''; // as string
LRange := Lsheet.Cells.Find('1234', XLApplication.ActiveCell); // as
oleVariant
while (not VarIsClear(LRange)) and (LFirstCellAddress <> LRange.Address)
do
begin
if LFirstCellAddress = '' then LFirstCellAddress := LRange.Address;
ListBox1.Items.Add(LRange.Address);
LRange := Lsheet.Cells.FindNext(LRange); // FindNext continues
searching
on criteria set up in Find function.
end;
hth,
Mariusz
"Bruce McIver" <b.mciver (AT) marlab (DOT) ac.uk> wrote in message
news:4141cecf$3 (AT) newsgroups (DOT) borland.com...
Quick question.
I'm using Delphi 7.
I open an excel file and search for a specific and unique value (e.g
1234)
in that file like so:
Excel.Selection.Find('1234', Excel.ActiveCell, xlFormulas, xlPart,
xlByRows,
xlNext, False).Activate;
Upon finding that value the cell that the value is in becomes the active
cell. How do I get back to Delphi information on which cell I have
actually
landed in (e.g. 'A10')?
Thanks in advance for any help.
Bruce
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|