use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; my $xl = Win32::OLE->new('Excel.Application'); $xl->{EnableEvents} = 0; $xl->{Visible} = 1; my $wb = $xl->Workbooks->Add; my $sht = $wb->Sheets(1); $sht->Cells(3,3)->{Value}="Here"; my $penultimate_column = $sht->UsedRange->SpecialCells(xlCellTypeLastCell)->{Column} - 1; print $penultimate_column;