Set page numbers in any cell in an Excel worksheet

Source: Internet
Author: User
Tags header

When you set up page number in Excel, most people would like to use Page setup, but have you ever thought of putting "nth page/Total M page" in any cell? Instead of just putting it in the header footer?

Method one, using VBA

Function page ()

page = (ActiveSheet.HPageBreaks.Count + 1) * (ActiveSheet.VPageBreaks.Count + 1)

Application.volatile

End Function

With VBA I only know the total number of methods, the current page number stumped me, but also please VBA master advice

Method Two, using the macro table function and the formula

1. First: Click ctrl+f3 to open the definition name, and then enter the "vertical page", in the following reference location, enter:

=if (MATCH (ROW (), GET, ISNA. DOCUMENT ()), 1,match (ROW (), get. DOCUMENT (64)) +1)

2. Then continue to add a second name: "Horizontal page", in the following reference location, enter:

=if (MATCH (column (), get. ISNA) DOCUMENT ()), 1,match (column (), get. DOCUMENT (65)) +1)

3. Enter the "Total page" and enter the reference position at:

=get. DOCUMENT (M) +rand () *0

4. Finally define "header", reference location:

= "&if" (horizontal as page =1, longitudinal page, horizontal as page + longitudinal page) & "page/Total" & Total Page & "page"

5. Use the application in the function bar to get the page number you need

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.