D Danny Aug 1, 2003 #1 Please help me with a command to count the number of sheets in a workbook. Thanks!
J Jason Morin Aug 1, 2003 #2 Try this macro: Sub Count_WS() Dim a As Integer a = ActiveWorkbook.Worksheets.Count MsgBox a & " worksheets" End Sub
Try this macro: Sub Count_WS() Dim a As Integer a = ActiveWorkbook.Worksheets.Count MsgBox a & " worksheets" End Sub
K Ken Wright Aug 1, 2003 #3 And just in case you want to count chart sheets as well, with a slight tweak on Jason's code:- Sub Count_WS() Dim a As Integer a = ActiveWorkbook.Worksheets.Count b = ActiveWorkbook.Charts.Count MsgBox a & " Worksheets, " & b & " Chart Sheets" End Sub or if you wanted it all lumped together, including any chart sheets Sub Count_WS() Dim a As Integer a = ActiveWorkbook.Sheets.Count MsgBox a & " Sheets" End Sub
And just in case you want to count chart sheets as well, with a slight tweak on Jason's code:- Sub Count_WS() Dim a As Integer a = ActiveWorkbook.Worksheets.Count b = ActiveWorkbook.Charts.Count MsgBox a & " Worksheets, " & b & " Chart Sheets" End Sub or if you wanted it all lumped together, including any chart sheets Sub Count_WS() Dim a As Integer a = ActiveWorkbook.Sheets.Count MsgBox a & " Sheets" End Sub
D Danny Aug 1, 2003 #5 Ken, This macro helps me a lot too! I was "manually" counting my chart sheets. Thanks a lot! Danny -----Original Message----- And just in case you want to count chart sheets as well, Click to expand... with a slight tweak on Jason's code:-
Ken, This macro helps me a lot too! I was "manually" counting my chart sheets. Thanks a lot! Danny -----Original Message----- And just in case you want to count chart sheets as well, Click to expand... with a slight tweak on Jason's code:-