Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
rm81
 
Posts: n/a
Default Count number of pages

Hi there,

I have an excel document with a variable number of pages and with various
named ranges. On the last page of my document I want to give the number of
pages in each named range i.e.
"ABC" = 2 pages
"DEF" = 4 pages
"GHI" = 3 pages etc

Is there a function or formula that exists that returns the number of pages
in these named ranges i.e. cell A500 = NBPAGES(range("ABC")) ?

If not, I presume I would have to do a macro. Taking into account the fact
that the result cells addresses are variable, does anyone have an idea of
what the code might be like?

Hope this makes sense!!
Thanks ever so much in advance for any contributions.
Regards,
rm81
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary L Brown
 
Posts: n/a
Default Count number of pages

This is a macro example using the 'ABC' range.
'/==============================================/
' Sub Purpose: Get the number of print pages in PrintArea of
' active worksheet
'
Sub GetPageCount()
Dim iView As Integer
Dim iHorizontalBreaks As Integer
Dim iVerticalBreaks As Integer
Dim iPageCount As Integer

On Error Resume Next

'go to the range and set PrintArea to the range name
Application.Goto Reference:="ABC"
ActiveSheet.PageSetup.PrintArea = Selection.Address

'turn monitor flickering/updating off
Application.ScreenUpdating = False

'remember current View setting
iView = Application.ActiveWindow.View

'refresh the print area
Application.ActiveWindow.View = xlPageBreakPreview

'set view back
Application.ActiveWindow.View = xlNormalView

'turn monitor flickering/updating back on
Application.ScreenUpdating = True

'calculate the # of pages
iHorizontalBreaks = ActiveSheet.HPageBreaks.Count + 1
iVerticalBreaks = ActiveSheet.VPageBreaks.Count + 1
iPageCount = iHorizontalBreaks * iVerticalBreaks

MsgBox iPageCount

End Sub
'/==============================================/
HTH,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"rm81" wrote:

Hi there,

I have an excel document with a variable number of pages and with various
named ranges. On the last page of my document I want to give the number of
pages in each named range i.e.
"ABC" = 2 pages
"DEF" = 4 pages
"GHI" = 3 pages etc

Is there a function or formula that exists that returns the number of pages
in these named ranges i.e. cell A500 = NBPAGES(range("ABC")) ?

If not, I presume I would have to do a macro. Taking into account the fact
that the result cells addresses are variable, does anyone have an idea of
what the code might be like?

Hope this makes sense!!
Thanks ever so much in advance for any contributions.
Regards,
rm81

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary L Brown
 
Posts: n/a
Default Count number of pages

'set view back
Application.ActiveWindow.View = xlNormalView

SHOULD BE...
'set view back
Application.ActiveWindow.View = iView

Sorry about that.
Sincerely,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"Gary L Brown" wrote:

This is a macro example using the 'ABC' range.
'/==============================================/
' Sub Purpose: Get the number of print pages in PrintArea of
' active worksheet
'
Sub GetPageCount()
Dim iView As Integer
Dim iHorizontalBreaks As Integer
Dim iVerticalBreaks As Integer
Dim iPageCount As Integer

On Error Resume Next

'go to the range and set PrintArea to the range name
Application.Goto Reference:="ABC"
ActiveSheet.PageSetup.PrintArea = Selection.Address

'turn monitor flickering/updating off
Application.ScreenUpdating = False

'remember current View setting
iView = Application.ActiveWindow.View

'refresh the print area
Application.ActiveWindow.View = xlPageBreakPreview

'set view back
Application.ActiveWindow.View = xlNormalView

'turn monitor flickering/updating back on
Application.ScreenUpdating = True

'calculate the # of pages
iHorizontalBreaks = ActiveSheet.HPageBreaks.Count + 1
iVerticalBreaks = ActiveSheet.VPageBreaks.Count + 1
iPageCount = iHorizontalBreaks * iVerticalBreaks

MsgBox iPageCount

End Sub
'/==============================================/
HTH,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"rm81" wrote:

Hi there,

I have an excel document with a variable number of pages and with various
named ranges. On the last page of my document I want to give the number of
pages in each named range i.e.
"ABC" = 2 pages
"DEF" = 4 pages
"GHI" = 3 pages etc

Is there a function or formula that exists that returns the number of pages
in these named ranges i.e. cell A500 = NBPAGES(range("ABC")) ?

If not, I presume I would have to do a macro. Taking into account the fact
that the result cells addresses are variable, does anyone have an idea of
what the code might be like?

Hope this makes sense!!
Thanks ever so much in advance for any contributions.
Regards,
rm81

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
rm81
 
Posts: n/a
Default Count number of pages

Dear Gary,

Thanks very much for that code - will try it out this weekend.

Have a good weekend yourself :)
rm81

"Gary L Brown" wrote:

'set view back
Application.ActiveWindow.View = xlNormalView

SHOULD BE...
'set view back
Application.ActiveWindow.View = iView

Sorry about that.
Sincerely,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"Gary L Brown" wrote:

This is a macro example using the 'ABC' range.
'/==============================================/
' Sub Purpose: Get the number of print pages in PrintArea of
' active worksheet
'
Sub GetPageCount()
Dim iView As Integer
Dim iHorizontalBreaks As Integer
Dim iVerticalBreaks As Integer
Dim iPageCount As Integer

On Error Resume Next

'go to the range and set PrintArea to the range name
Application.Goto Reference:="ABC"
ActiveSheet.PageSetup.PrintArea = Selection.Address

'turn monitor flickering/updating off
Application.ScreenUpdating = False

'remember current View setting
iView = Application.ActiveWindow.View

'refresh the print area
Application.ActiveWindow.View = xlPageBreakPreview

'set view back
Application.ActiveWindow.View = xlNormalView

'turn monitor flickering/updating back on
Application.ScreenUpdating = True

'calculate the # of pages
iHorizontalBreaks = ActiveSheet.HPageBreaks.Count + 1
iVerticalBreaks = ActiveSheet.VPageBreaks.Count + 1
iPageCount = iHorizontalBreaks * iVerticalBreaks

MsgBox iPageCount

End Sub
'/==============================================/
HTH,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"rm81" wrote:

Hi there,

I have an excel document with a variable number of pages and with various
named ranges. On the last page of my document I want to give the number of
pages in each named range i.e.
"ABC" = 2 pages
"DEF" = 4 pages
"GHI" = 3 pages etc

Is there a function or formula that exists that returns the number of pages
in these named ranges i.e. cell A500 = NBPAGES(range("ABC")) ?

If not, I presume I would have to do a macro. Taking into account the fact
that the result cells addresses are variable, does anyone have an idea of
what the code might be like?

Hope this makes sense!!
Thanks ever so much in advance for any contributions.
Regards,
rm81

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
count the number of times the same number shown Noemi Excel Discussion (Misc queries) 1 September 22nd 05 04:00 AM
Count number of cells that contain a certain letter - Case Sensitive elite Excel Discussion (Misc queries) 4 September 20th 05 01:41 PM
Count the number of Cells in one ROW with conditions Amanda Excel Worksheet Functions 2 September 9th 05 04:03 PM
Count Number of Characters in a cell? AHJuncti Excel Discussion (Misc queries) 2 June 16th 05 07:39 PM
Count number of days in given month? Bryan Excel Worksheet Functions 10 February 2nd 05 11:44 PM


All times are GMT +1. The time now is 09:44 AM.

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

About Us

"It's about Microsoft Excel"