Range(Selection, Selection.End(xlDown)).Select

4.4k Views Asked by At

How can I convert the following excel vba statement to perl win32::ole statement?

Range(Selection, Selection.End(xlDown)).Select

I've converted as follows, but doesn't work:

my $Excel = CreateObject OLE "Excel.Application";
my $SecondSht = $Book->ActiveSheet;
$SecondSht->Range("P2")->Select();
$SecondSht->Range({$Excel->Selection(), {$Excel->Selection()->End({xlDown})})->Select(); #fails at this statement
$Excel->Selection->Copy;
$SecondSht->Range({"Q2"})->Select;
$SecondSht->Paste;
1

There are 1 best solutions below

0
On BEST ANSWER

I got the answer!

$SecondSht->Range($SecondSht->Range("P2"), $SecondSht->Range("P2")->End(xlDown))->Select();
$Excel->Selection->Copy;
$SecondSht->Range("Q2")->Select();
$SecondSht->Paste;