perlexcelwin32olevba

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


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;

Solution

  • I got the answer!

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