Need index of sheets with page number

Hudco

Board Regular
Joined
Jan 4, 2006
Messages
131
Office Version
  1. 365
Looking for help after hours of research. I have a workbook with 35 sheets. Various sheets are hidden and are "Unhidden" depending on the report required.

I have a VBA macro that lists the required sheets that make up the index. What I want to do is list the page number but some sheets print different numbers of pages.

My macro for listing the sheets is as follows

Private Sub CommandButton1_Click()
Sheets("Index").Select
ActiveSheet.Unprotect
Range("B29", Range("B31").End(xlDown)).Select
Selection.ClearContents
Range("B29").Select
Dim bCell As Range
Dim wt As Worksheet
Set bCell = ThisWorkbook.Worksheets("Index").Range("B29")
For Each wt In ThisWorkbook.Worksheets
If wt.Name <> "Data" And wt.Name <> "Cover" And wt.Name <> "Index" And wt.Name <> "TrialBal" And wt.Visible Then
wt.Range("U1").Copy
bCell.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, Transpose:=False
Set bCell = bCell.Offset(1, 0)
End If
Next wt
End Sub

Cell "U1" contains the name of the sheet for the purposes of the index. This is done because the names can be several words and also dynamic.

Any help much appreciated.
Clyde
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
When I wanted a report that only prints certain worksheets, I would hide the sheets I did not want printed, then printed the entire workbook, the page numbers in the header or footer would always be correct. provided the sheet tabs were in the correct order.
 
Upvote 0
Oops, sorry Dave.

I am trying to have the index page show the page number in the cell next to the name of the sheet as constructed by the VBA macro.

That is, I need macro code to add to the earlier code to post the page number for each sheet.. You are correct in terms of printing which is what I do. I have anothr macro that hides the sheets not "ticked".

Thanks,

Clyde
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top