Hello, can anyone tell me how I can count the amount of sheet I have in a workbook? Thanks so much, Tira
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Excel XP (Counting sheets)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Excel XP (Counting sheets)
- This topic has 17 replies, 8 voices, and was last updated 21 years, 3 months ago.
Viewing 1 reply threadAuthorReplies-
WSWassim
AskWoody Lounger -
WSBrooke
AskWoody LoungerApril 19, 2002 at 5:15 pm #583401severely edited/completely rewritten by Brooke, 18:15 BST
Okay, to do this without VBA you need to go Insert:Name:Define, call the new name getdoc87, and type the following in the refers to box:
=GET.DOCUMENT(87,”Sheet3″)
where Sheet3 is the name of the last sheet in the workbook. Now in any cell anywhere in the workbook, type “=getdoc87” and the resulting number is the number of sheets in the book. On a similar note, if you define the name as “=GET.DOCUMENT(87)” then then =getdoc87 will result in the index of that sheet.
Limitations: this is actually returning the index of the referenced sheet (including hidden sheets,) so if you move the last sheet or add another after it it will fall over. I don’t know how to call total sheets from GET.DOCUMENT or even if it’s possible, though you’d think it would be – hopefully Jan Karel will be able to point us in the right direction.
-
WSGlennB
AskWoody Lounger -
WSBrooke
AskWoody Lounger -
WSAndrew Cronnolly
AskWoody Lounger
-
-
-
WSWebGenii
AskWoody Lounger -
WSBrooke
AskWoody LoungerApril 22, 2002 at 8:40 am #583734if you mean in refers to, because that was the relevant type_num. See below for a full listing of the options – from macrofun.hlp, courtesy of microsoft. [Jan Karel has provided a url below if you wish to get your own copy of this]
if you mean in the name of the name, you only need a few names like this and you – Well, I would anyway! – become hopelessly confused. Maybe there’s a better (descriptive?) convention but I just went for the number.
GET.DOCUMENT
Macro Sheets Only
Returns information about a sheet in a workbook.Syntax
GET.DOCUMENT(type_num, name_text)
Type_num is a number that specifies what type of information you want. The following lists show the possible values of type_num and the corresponding results.
Type_num Returns
1 Returns the name of the workbook and worksheet as text. If there is only one sheet in the workbook and the sheet name is the same as the workbook name less any extension, returns the name of the book. The book name does not include the drive, directory or folder, or window number. Otherwise, returns the book and sheet name in the form “[BOOK1.XLS]Sheet1”. It is usually best to use GET.DOCUMENT(76) and GET.DOCUMENT(88) to return the name of the active worksheet and the active workbook.
2 Path of the directory or folder containing name_text, as text. If the workbook name_text hasn’t been saved yet, returns the #N/A error value.
3 Number indicating the type of sheet. If name_text is a sheet, then the return value is one of the following numbers. If name_text is a book, then the return value is always 5. If name_text is omitted, then the sheet type is returned. If the book has one sheet that is named the same as the book, then the sheet type is returned.
1 = Worksheet
2 = Chart
3 = Macro sheet
4 = Info window if active
5 = Reserved
6 = Module
7 = Dialog4 If changes have been made to the sheet since it was last saved, returns TRUE; otherwise, returns FALSE.
5 If the sheet is read-only, returns TRUE; otherwise, returns FALSE.
6 If the sheet is password protected, returns TRUE; otherwise, returns FALSE.
7 If cells in a sheet, the contents of a sheet, or the series in a chart are protected, returns TRUE; otherwise, returns FALSE.
8 If the workbook windows are protected, returns TRUE; otherwise, returns FALSE.The next four values of type_num apply only to charts.
Type_num Returns
9 Number indicating the type of the main chart:
1 = Area
2 = Bar
3 = Column
4 = Line
5 = Pie
6 = XY (scatter)
7 = 3-D area
8 = 3-D column
9 = 3-D line
10 = 3-D pie
11 = Radar
12 = 3-D bar
13 = 3-D surface
14 = Donut
10 Number indicating the type of the overlay chart. Same as 1, 2, 3, 4, 5, 6, 11, and 14 for main chart above. If there is no overlay chart, returns the #N/A error value.
11 Number of series in the main chart.
12 Number of series in the overlay chart.The next values of type_num apply to worksheets and macro sheets and to charts when appropriate.
Type_num Returns
9 Number of the first used row. If the document is empty, returns 0.
10 Number of the last used row. If the document is empty, returns 0.
11 Number of the first used column. If the document is empty, returns 0.
12 Number of the last used column. If the document is empty, returns 0.
13 Number of windows.
14 Number indicating calculation mode:
1 = Automatic
2 = Automatic except tables
3 = Manual
15 If the Iteration check box is selected in the Calculation tab of the Options dialog box, returns TRUE; otherwise, returns FALSE.16 Maximum number of iterations.
17 Maximum change between iterations.
18 If the Update Remote References check box is selected in the Calculation tab of the Options dialog box, returns TRUE; otherwise, returns FALSE.
19 If the Precision As Displayed check box is selected in the Calculation tab of the Options dialog box, returns TRUE; otherwise, returns FALSE.
20 If the 1904 Date System check box is selected in the Calculation tab of the Options dialog box, returns TRUE; otherwise, returns FALSE.Type_num values of 21 through 29 correspond to the four default fonts in previous versions of Microsoft Excel. These values are provided only for macro compatibility.
The next values of type_num apply to worksheets and macro sheets, and to charts if indicated.Type_num Returns
30 Horizontal array of consolidation references for the current sheet, in the form of text. If the list is empty, returns the #N/A error value.
31 Number from 1 to 11, indicating the function used in the current consolidation. The function that corresponds to each number is listed under the CONSOLIDATE function. The default function is SUM.
32 Three-item horizontal array indicating the status of the check boxes in the Data Consolidate dialog box. An item is TRUE if the check box is selected or FALSE if the check box is cleared. The first item indicates the Top Row check box, the second the Left Column check box, and the third the Create Links To Source Data check box.33 If the Recalculate Before Saving check box is selected in the Calculation tab of the Options dialog box, returns TRUE; otherwise, returns FALSE.
34 If the workbook is read-only recommended, returns TRUE; otherwise, returns FALSE.
35 If the workbook is write-reserved, returns TRUE; otherwise, returns FALSE.
36 If the document has a write-reservation password and it is opened with read/write permission, returns the name of the user who originally saved the file with the write-reservation password. If the file is opened as read-only, or if a password has not been added to the document, returns the name of the current user.37 Number corresponding to the file type of the document as displayed in the Save As dialog box. See the SAVE.AS function for a list of all the file types that Microsoft Excel recognizes.
38 If the Summary Rows Below Detail check box is selected in the Outline dialog box, returns TRUE; otherwise, returns FALSE.
39 If the Summary Columns To Right Of Detail check box is selected in the Outline dialog box, returns TRUE; otherwise, returns FALSE.
40 If the Create Backup File check box is selected in the Save As dialog box, returns TRUE; otherwise, returns FALSE.41 Number from 1 to 3 indicating whether objects are displayed:
1 = All objects are displayed
2 = Placeholders for pictures and charts
3 = All objects are hidden
42 Horizontal array of all objects in the sheet. If there are no objects, returns the #N/A error value.
43 If the Save External Link Values check box is selected in the Calculation tab of the Options dialog box, returns TRUE; otherwise, returns FALSE.
44 If objects in a document are protected, returns TRUE; otherwise, returns FALSE.45 A number from 0 to 3 indicating how windows are synchronized:
0 = Not synchronized
1 = Synchronized horizontally
2 = Synchronized vertically
3 = Synchronized horizontally and vertically
46 A seven-item horizontal array of print settings that can be set by the LINE.PRINT macro function:
– Setup text
– Left margin
– Right margin
– Top margin
– Bottom margin
– Page length– A logical value indicating whether output will be formatted (TRUE) or unformatted (FALSE) when printed
47 If the Transition Expression Evaluation check box is selected in the Transition tab of the Options dialog box, returns TRUE; otherwise, returns FALSE.
48 The standard column width setting.The next values of type_num correspond to printing and page settings.
Type_num Returns
49 The starting page number, or the #N/A error value if none is specified or if “Auto” is entered in the First page Number text box on the Page tab of the Page Setup dialog box.
50 The total number of pages that would be printed based on current settings, excluding notes, or 1 if the document is a chart.
51 The total number of pages that would be printed if you print only notes, or the #N/A error value if the document is a chart.
52 Four-item horizontal array indicating the margin settings (left, right, top, bottom) in the currently specified units.53 A number indicating the orientation:
1 = Portrait
2 = Landscape
54 The header as a text string, including formatting codes.
55 The footer as a text string, including formatting codes.
56 Horizontal array of two logical values corresponding to horizontal and vertical centering.
57 If row or column headings are to be printed, returns TRUE; otherwise, returns FALSE.
58 If gridlines are to be printed, returns TRUE; otherwise, returns FALSE.
59 If the sheet is printed in black and white only, returns TRUE; otherwise, returns FALSE.60 A number from 1 to 3 indicating how the chart will be sized when it’s printed:
1 = Size on screen
2 = Scale to fit page
3 = Use full page
61 A number indicating the pagination order:
1 = Down, then Over
2 = Over, then Down
Returns the #N/A error value if the document is a chart.
62 Percentage of reduction or enlargement, or 100% if none is specified. Returns the #N/A error value if not supported by the current printer or if the document is a chart.
63 A two-item horizontal array indicating the number of pages to which the printout should be scaled to fit, with the first item equal to the width (or #N/A if no width scaling is specified) and the second item equal to the height (or #N/A if no height scaling is specified). #N/A is also returned if the document is a chart.64 An array of row numbers corresponding to rows that are immediately below a manual or automatic page break.
65 An array of column numbers corresponding to columns that are immediately to the right of a manual or automatic page break.Note GET.DOCUMENT(62) and GET.DOCUMENT(63) are mutually exclusive. If one returns a value, then the other returns the #N/A error value.
The next values of type_num correspond to various document settings.
Type_num Returns
66 In Microsoft Excel for Windows, if the Transition Formula Entry check box is selected in the Transition tab of the Options dialog box, returns TRUE; otherwise, returns FALSE.
67 Microsoft Excel 5.0 or later always returns TRUE here.
68 Microsoft Excel 5.0 or later always returns the book name.
69 Returns TRUE if Automatic Page Breaks is chosen in the View tab of the Options dialog box; otherwise, returns FALSE.
70 Returns the names of all PivotTables in the current sheet as a horizontal array.71 Returns an horizontal array of all the styles in a document.
72 Returns an horizontal array of all chart types displayed on the current sheet.
73 Returns an array of the number of series in each chart of the current sheet.
74 Returns the object id of the control that currently has the focus on a running user-defined dialog (based on the dialog sheet).
75 Returns the object id of the object that is the current default button on a running user-defined dialog (based on the dialog sheet).76 Returns the name of the active sheet or macro sheet in the form [Book1]Sheet1.
77 In Microsoft Excel for Windows, returns the paper size, as integer:
1 = Letter 8.5 x 11 in
2 = Letter Small 8.5 x 11 in
5 = Legal 8.5 x 14 in
9 = A4 210 x 297 mm
10 = A4 Small 210 x 297 mm
13 = B5 182 x 257 mm
18 = Note 8.5 x 11 in
78 Returns the print resolution, as a horizontal array of two numbers.
79 Returns TRUE if the Draft Quality check box has been selected from the sheet tab in the Page Setup dialog box; otherwise, returns FALSE.80 Returns TRUE if the Notes checkbox has been selected on the Sheet tab in the Page Setup dialog box; otherwise, returns FALSE.
81 Returns the print area from the Sheet tab of the Page Setup dialog box as a cell reference.
82 Returns the print titles from the Sheet tab of the Page Setup dialog box as an array of cell references.
83 Returns TRUE if the worksheet is protected for scenarios; otherwise, returns FALSE.
84 Returns the value of the first circular reference on the sheet, or #N/A if there are no circular references.85 Returns the advanced filter mode state of the sheet. This is the mode without drop-down arrows on top. Returns TRUE if the list has been filtered by choosing Filter, then Advanced Filter from the Data menu. Otherwise, returns FALSE.
86 Returns the automatic filter mode state of the sheet. This is the mode with drop-down arrows on top. Returns TRUE if you have chosen Filter, then AutoFilter from the Data menu and the filter drop-down arrows are displayed. Otherwise, returns FALSE.87 Returns the position number of the sheet. The first sheet is position 1. Hidden sheet are included in the count.
88 Returns the name of the active workbook in the form “Book1”.Name_text is the name of an open document. If name_text is omitted, it is assumed to be the active document.
Examples
The following macro formula returns TRUE if the contents of the active document are protected:
GET.DOCUMENT(7)
In Microsoft Excel for Windows, the following macro formula returns the number of windows in SALES.XLS:
GET.DOCUMENT(13, “SALES.XLS”)
In Microsoft Excel for the Macintosh, the following macro formula returns 3 if the overlay chart on SALES CHART is a column chart:
GET.DOCUMENT(10, “SALES CHART”)
To find out if SHEET1 is password-protected and if its contents and windows are protected, enter the following formula in a three-cell horizontal array:
GET.DOCUMENT({6, 7, 8}, “SHEET1”)
Related Functions
GET.CELL Returns information about the specified cell
GET.WINDOW Returns information about a window
GET.WORKSPACE Returns information about the workspaceList of Information Functions
-
WSWebGenii
AskWoody Lounger -
WSpieterse
AskWoody LoungerMarch 13, 2004 at 5:04 pm #583799Have a look at my arg2name.zip from
http://www.bmsltd.ie/mvp%5B/url%5D
to see some advanced stuff with GET.CELLEdited Mar 13th 2004 to update link
-
WSandrewgibsonsw
AskWoody Lounger -
WSBrooke
AskWoody LoungerApril 22, 2002 at 12:53 pm #583830You want a list of undocumented features?
Seriously though, some of the things that spring to mind are the easter eggs, the hidden name space, the excel 4.0 code in defined names, the camera button….. the non existant list goes on!
have a look here for starters: http://j-walk.com/ss/excel/odd/%5B/url%5D
-
WSpieterse
AskWoody LoungerApril 22, 2002 at 5:55 am #583798Here is one place to find it:
http://forums.compuserve.com/scripts/flisa…2000&FVF=1/.EXE%5B/url%5D
-
-
-
WSWassim
AskWoody LoungerApril 22, 2002 at 2:36 pm #583845Brooke
This thread was started by Tira, and I think it would be better to address the posts to the “owner” of the thread. This is my humble point of view only, but I wish to have messages addressed to me when I start a thread unless someone, myself included, submits something that is incomplete and then you would need to correct it.
I had seen a thread asking to have the facility to address a message to many loungers at the same time. I think this is a great idea.
Thanks for listening
Wassim
-
WSBrooke
AskWoody LoungerApril 22, 2002 at 4:57 pm #583856Wassim.
>>>This thread was started by Tira, and I think it would be better to address the posts to the “owner” of the thread.
But Tira didn’t ask about undocumented features. Andrewgibsonsw did.
Yup, you’ve guessed it – I disagree with you.
Let me try and explain my view point: Conversations twist. You ask me something, I respond. If you don’t come straight back with a comment/observation/request for clarification someone else pipes up with a comment/observation/request for clarification to either me or you. If every question and response in this thread was posted as a reply to Tira’s original post it would soon become hopless to follow. And if Tira had to act as spacer for every post, it would get tedious.
I do agree with you in as far as there are some threads that I get involved in to the extent that I am interested in knowing the latest updates as soon as they are there. If I’m that interested I add them to the watched threads list. No emails means no-one’s replied to me directly but all I have to do is knock on the front door of the lounge and I can see the following attachment reproduced below. Works for me!
>>>I had seen a thread asking to have the facility to address a message to many loungers at the same time. I think this is a great idea.
I think that depends on precisely what you mean by that sentence.
I don’t want you (or anyone else, it’s not a personal thing, you understand) deciding that it would be really cool to email the entire list of loungers that have posted to the excel board everytime you make a new post there. One person doing it probably wouldn’t be too bad, but it wouldn’t be just one. And I struggle to keep my inbox empty as it is anyway.
If, however you mean that you would like the ability to opt into email notification for any new posting to a particular thread, then yes, this is a good idea, and yes you have seen a thread about it. I think, if I remember correctly, that the idea was awarded enough merit by Ian for him to put it on the to-do list. However, even if my memory is correct (a rare thing), that list is mighty long and things like keeping the lounge up and running take slightly more priority than the wish list.
>>>Thanks for listening
no problems – except for you: now you’ve got to listen to me!
-
-
-
-
WSWassim
AskWoody LoungerApril 22, 2002 at 2:27 pm #583843 -
WSTira
AskWoody LoungerApril 23, 2002 at 1:18 am #583912Hello to everyone who responded to my question. Thank you so much. As I’ve been out of town I haven’t noticed nor tried any of your suggestions, however, I WILL. This is such a great place, everyone is so helpful. I’m sorry if I started something I was not supposed to, but just wanted to ask a question.
I appreciate all your help.
Thanks,
Tira -
WSWebGenii
AskWoody Lounger
-
-
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Apk on iphone (Awaiting moderation)
by
Calluum
5 minutes ago -
Are Macs immune?
by
Susan Bradley
3 hours, 20 minutes ago -
HP Envy and the Function keys
by
CWBillow
3 hours, 48 minutes ago -
Microsoft : Removal of unwanted drivers from Windows Update
by
Alex5723
5 hours, 12 minutes ago -
MacOS 26 beta 1 dropped support for Firewire 400/800
by
Alex5723
5 hours, 29 minutes ago -
Unable to update to version 22h2
by
04om
5 hours, 49 minutes ago -
Windows 11 Insider Preview Build 26100.4482 (24H2) released to Release Preview
by
joep517
12 hours, 57 minutes ago -
Windows 11 Insider Preview build 27881 released to Canary
by
joep517
13 hours ago -
Very Quarrelsome Taskbar!
by
CWBillow
4 hours, 7 minutes ago -
Move OneNote Notebook OFF OneDrive and make it local
by
CWBillow
1 day, 1 hour ago -
Microsoft 365 to block file access via legacy auth protocols by default
by
Alex5723
14 hours, 42 minutes ago -
Is your battery draining?
by
Susan Bradley
7 hours, 49 minutes ago -
The 16-billion-record data breach that no one’s ever heard of
by
Alex5723
4 hours, 49 minutes ago -
Weasel Words Rule Too Many Data Breach Notifications
by
Nibbled To Death By Ducks
1 day, 5 hours ago -
Windows Command Prompt and Powershell will not open as Administrator
by
Gordski
13 hours, 54 minutes ago -
Intel Management Engine (Intel ME) Security Issue
by
PL1
14 hours, 6 minutes ago -
Old Geek Forced to Update. Buy a Win 11 PC? Yikes! How do I cope?
by
RonE22
6 hours, 46 minutes ago -
National scam day
by
Susan Bradley
13 hours, 38 minutes ago -
macOS Tahoe 26 the end of the road for Intel Macs, OCLP, Hackintosh
by
Alex5723
9 hours, 48 minutes ago -
Cyberattack on some Washington Post journalists’ email accounts
by
Bob99
2 days, 6 hours ago -
Tools to support internet discussions
by
Kathy Stevens
19 hours, 33 minutes ago -
How get Group Policy to allow specific Driver to download?
by
Tex265
1 day, 21 hours ago -
AI is good sometimes
by
Susan Bradley
2 days, 14 hours ago -
Mozilla quietly tests Perplexity AI as a New Firefox Search Option
by
Alex5723
2 days, 4 hours ago -
Perplexity Pro free for 12 mos for Samsung Galaxy phones
by
Patricia Grace
3 days, 14 hours ago -
June KB5060842 update broke DHCP server service
by
Alex5723
3 days, 12 hours ago -
AMD Ryzen™ Chipset Driver Release Notes 7.06.02.123
by
Alex5723
3 days, 16 hours ago -
Excessive security alerts
by
WSSebastian42
2 days, 7 hours ago -
* CrystalDiskMark may shorten SSD/USB Memory life
by
Alex5723
4 days, 2 hours ago -
Ben’s excellent adventure with Linux
by
Ben Myers
16 hours, 37 minutes ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.