BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Excel - adressing multiple non-adjacent cells..

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Bogdan X
Guest





PostPosted: Mon Jan 10, 2005 7:26 pm    Post subject: Excel - adressing multiple non-adjacent cells.. Reply with 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
Mariusz Celmer
Guest





PostPosted: Tue Jan 11, 2005 9:35 am    Post subject: Re: Excel - adressing multiple non-adjacent cells.. Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.