Friday, May 1, 2015

Counting Excel sheets and rows

To count the number of individual sheets in an Excel workbook using VBA

[Excel 2010] Go to VBA, by pressing ALT + F11. Activate the Immediate window by Pressing CTRL + G

Enter the following line and press enter.

?activeworkbook.Sheets.Count


To count number of rows in a named worksheet enter the following:

?Sheets("Sheet1").UsedRange.Rows.Count



The total number of rows across an entire Excel workbook can also be calculated using VBA. But this is how to do it using Perl.