Excel VBA -如何插入顺序页码

时间:2021-01-02 02:29:00

I would like to insert sequential page number across the entire workbook (there are two worksheets in the workbook.

我想在整个工作簿中插入顺序页码(工作簿中有两个工作表。

Here is my code to insert page numbers:

这是我插入页码的代码:

ActiveWorkbook.Worksheets("Appendix A").PageSetup.CenterFooter = "&P of &N"
ActiveWorkbook.Worksheets("Summary").PageSetup.CenterFooter = "&P of &N"

1 个解决方案

#1


1  

If you mean you want to write the index of the current sheet out of the entire number of sheets in your ActiveWorkbook, then use the following code:

如果您的意思是您想要在您的ActiveWorkbook中列出所有表的当前页的索引,那么请使用以下代码:

ActiveWorkbook.Worksheets("Appendix A").PageSetup.CenterFooter = "Page " & ActiveWorkbook.Worksheets("Appendix A").Index & " of " & ActiveWorkbook.Sheets.Count
ActiveWorkbook.Worksheets("Summary").PageSetup.CenterFooter = "Page " & ActiveWorkbook.Worksheets("Summary").Index & " of " & ActiveWorkbook.Sheets.Count

#1


1  

If you mean you want to write the index of the current sheet out of the entire number of sheets in your ActiveWorkbook, then use the following code:

如果您的意思是您想要在您的ActiveWorkbook中列出所有表的当前页的索引,那么请使用以下代码:

ActiveWorkbook.Worksheets("Appendix A").PageSetup.CenterFooter = "Page " & ActiveWorkbook.Worksheets("Appendix A").Index & " of " & ActiveWorkbook.Sheets.Count
ActiveWorkbook.Worksheets("Summary").PageSetup.CenterFooter = "Page " & ActiveWorkbook.Worksheets("Summary").Index & " of " & ActiveWorkbook.Sheets.Count