 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bogdan X Guest
|
Posted: Mon Jan 10, 2005 7:26 pm Post subject: Excel - adressing multiple non-adjacent cells.. |
|
|
I need to select some cells in Excel that are on the same row, but not near
one another. I am using the TExcelApplication server in D7. I have tried:
exa.Range['D2,D3,D7', 'D2,D3,D7'].Select;
exa.Range['D2,D3,D7', EmptyParam].Select;
exa.Range['D2', 'D3,D7'].Select;
and none worked (exa.Range['D2', 'D7'].Select works, but it selects all
the cells on the way too..)
The VBA documentation and Google don't seem to turn up too much
(I was looking for an alternate way of addressing it) - does anybody
how this could be done?
|
|
| Back to top |
|
 |
Mariusz Celmer Guest
|
Posted: Tue Jan 11, 2005 9:35 am Post subject: Re: Excel - adressing multiple non-adjacent cells.. |
|
|
Hello, I've got 2 ideas:
first try to change "," with ";":
LSheet.Range['A1;C1;E1', EmptyParam].Select;
other way is to make an union of ranges:
LRange := LSheet.Range['A1', EmptyParam];
LRange := XLApplication.Union(LRange, LSheet.Range['C1', EmptyParam]);
LRange := XLApplication.Union(LRange, LSheet.Range['E1', EmptyParam]);
LRange.Select;
example above is better to use in some loop with cells refering:
LRange := LSheet.Cells.Item[1, 1];
i := 3;
while i < 10 do
begin
LRange := XLApplication.Union(LRange, LSheet.Cells.Item[1, i]);
i := i + 2;
end;
LRange.Select;
hth,
Mariusz
"Bogdan X"
| Quote: | I need to select some cells in Excel that are on the same row, but not
near
one another. I am using the TExcelApplication server in D7. I have tried:
exa.Range['D2,D3,D7', 'D2,D3,D7'].Select;
exa.Range['D2,D3,D7', EmptyParam].Select;
exa.Range['D2', 'D3,D7'].Select;
and none worked (exa.Range['D2', 'D7'].Select works, but it selects all
the cells on the way too..)
The VBA documentation and Google don't seem to turn up too much
(I was looking for an alternate way of addressing it) - does anybody
how this could be done?
|
|
|
| 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
|
|