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
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