Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic Table of Contents

Hi Everyone,

I have a workbook that has 28 sheets. This workbook is meant to be
printed out. Several of the sheets run for more than one page. For
example, sheet 5 may be made up of 3 pages. Because the information is
pulled from a database automatically, the number of pages per sheet
varies.

I would like to create a dynamic TOC that counts the pages of each
sheet and displays it. For example:

Contractors ..............................pages 10-15
Vendors....................................pages 16-18

And so on. Anyone have any ideas of an easy way to do this?

Thanks!

Frankie


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Dynamic Table of Contents

Hi
maybe the following site will help you
http://www.tushar-mehta.com/excel/so...toc/index.html

Frank

Hi Everyone,

I have a workbook that has 28 sheets. This workbook is meant to be
printed out. Several of the sheets run for more than one page. For
example, sheet 5 may be made up of 3 pages. Because the information
is pulled from a database automatically, the number of pages per

sheet
varies.

I would like to create a dynamic TOC that counts the pages of each
sheet and displays it. For example:

Contractors ..............................pages 10-15
Vendors....................................pages 16-18

And so on. Anyone have any ideas of an easy way to do this?

Thanks!

Frankie


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Dynamic Table of Contents

Take a look at

Build Table of Contents, similar listings, working with Hyperlinks
http://www.mvps.org/dmcritchie/excel/buildtoc.htm

and

Build TOC Another Approach
http://www.mvps.org/dmcritchie/excel/excel.htm



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"PRGMRgirl " wrote in message
...
Hi Everyone,

I have a workbook that has 28 sheets. This workbook is meant to be
printed out. Several of the sheets run for more than one page. For
example, sheet 5 may be made up of 3 pages. Because the information is
pulled from a database automatically, the number of pages per sheet
varies.

I would like to create a dynamic TOC that counts the pages of each
sheet and displays it. For example:

Contractors ..............................pages 10-15
Vendors....................................pages 16-18

And so on. Anyone have any ideas of an easy way to do this?

Thanks!

Frankie


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Dynamic Table of Contents

The code below assumes that pagebreak settings are already
'effective' / 'initialized' (or whatever the correct terminology is).

You will have to adapt the code below to suit your aesthetic needs.

Option Explicit
Option Base 0
Type SheetData
SheetName As String
PageCount As Integer
End Type
Sub Macro5()
Dim i As Integer, aSheet As Object, WbkData() As SheetData
ReDim WbkData(ActiveWorkbook.Sheets.Count - 1)
On Error Resume Next
For i = 1 To ActiveWorkbook.Sheets.Count
With Sheets(i)
WbkData(i - 1).PageCount = _
(.HPageBreaks.Count + 1) * (.VPageBreaks.Count + 1)
WbkData(i - 1).SheetName = .Name
End With
If Err.Number < 0 Then WbkData(i - 1).PageCount = -1
Err.Clear
Next i
On Error GoTo 0
Dim NewWKS As Worksheet
Set NewWKS = ActiveWorkbook.Worksheets.Add()
For i = LBound(WbkData) To UBound(WbkData)
With NewWKS.Cells(1, 1)
.Offset(i + 1, 0).Value = WbkData(i).SheetName
.Offset(i + 1, 1).Value = WbkData(i).PageCount
.Offset(i + 1, 2).Value = _
Application.WorksheetFunction.Max(1, _
.Offset(i, 2).Value + .Offset(i, 1).Value)
End With
Next i
With NewWKS.Cells(1, 1)
.Offset(0, 0).Value = "Name"
.Offset(0, 1).Value = "Pages"
.Offset(0, 2).Value = "Start Page"

End With
End Sub

If page break data is not updated, adapt the ideas in the code below to
'initialize' each sheet in the workbook.

Sub Macro6()
Dim InitView, InitShowPageBreak
InitView = ActiveWindow.View
ActiveWindow.View = xlNormalView
InitShowPageBreak = ActiveSheet.DisplayAutomaticPageBreaks
ActiveSheet.DisplayAutomaticPageBreaks = True
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.View = InitView
ActiveSheet.DisplayAutomaticPageBreaks = InitShowPageBreak
End Sub

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , PRGMRgirl
says...
Hi Everyone,

I have a workbook that has 28 sheets. This workbook is meant to be
printed out. Several of the sheets run for more than one page. For
example, sheet 5 may be made up of 3 pages. Because the information is
pulled from a database automatically, the number of pages per sheet
varies.

I would like to create a dynamic TOC that counts the pages of each
sheet and displays it. For example:

Contractors ..............................pages 10-15
Vendors....................................pages 16-18

And so on. Anyone have any ideas of an easy way to do this?

Thanks!

Frankie


---
Message posted from http://www.ExcelForum.com/


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic pivot table linked to dynamic excel spreadsheets FErd Excel Worksheet Functions 0 April 29th 10 10:44 PM
dynamic range with a table below the working table Robert H Excel Worksheet Functions 9 March 17th 08 01:41 PM
Any way to link comments (dynamic) to another cell's contents? KR Excel Discussion (Misc queries) 1 June 27th 06 05:06 PM
Dynamic contents of commens box AB Excel Worksheet Functions 2 November 30th 04 12:58 AM
create a source table from a special pasted value dynamic crossed table Tom Ogilvy Excel Programming 0 September 29th 03 08:59 PM


All times are GMT +1. The time now is 07:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"