How do I know how many worksheets are in a workbook?

Source: Internet
Author: User

Method One,

(1), open the Tools menu, select the macro Visual Basic Editor command, as shown in the figure:

(2), in the open window select the "Insert" → "module" command, as shown in the figure:

(3) Enter the following content, as shown in the picture:

Sub Sheetcount ()

Dim Num as Integer

Num=thisworkbook.sheets.count

Sheets (1). Select

Cells (1,1) =num

End Sub

(4), run the macro, the number in the A1 cell of the first worksheet in the workbook is the number of worksheets.

Method Two,

(1) Press the "CTRL+F3" key combination, open the Define Name dialog box, define an X, enter "=get.workbook (4)" At the reference location, and then click OK, as shown in the picture:

(2) Enter "=x" in any cell, and the result is the number of worksheets.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.