foreach my $col ( 'A' .. 'XFD' ) # Assuming >= Office 2007 { foreach my $row ( 1 .. 300) { next unless defined $Sheet->Cells("$col$row")->{Value}; # the rest of your code here } }