PC Review


Reply
Thread Tools Rate Thread

how to count number of pages in worksheet

 
 
msnews
Guest
Posts: n/a
 
      8th Apr 2008
i want to insert the count of total number of pages of a worksheet in a cell
of the same worksheet.
this should be done automatically using worksheet formula or visual basic
code or macro.
please help


 
Reply With Quote
 
 
 
 
NateBuckley
Guest
Posts: n/a
 
      8th Apr 2008
Hello I hope this helps, go to the code in ThisWorkBook.

You can do this by pushing ALT+F11 then right clicking on "ThisWorkBook" on
the left, and left clicking on view code.

Then paste in the following

Private Sub Workbook_Open()
Sheets("NameOfSheet").Cells(1, 1).Value = Worksheets.Count
End Sub

When the worksheet opens it'll count the number of worksheets and put this
value in a specified cell. So in this case if you had a sheet named
NameOfSheet it would put a number in Row 1, Column A.

Hope this helped.

"msnews" wrote:

> i want to insert the count of total number of pages of a worksheet in a cell
> of the same worksheet.
> this should be done automatically using worksheet formula or visual basic
> code or macro.
> please help
>
>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      8th Apr 2008
I am reading your question differently than Nate did... it looks to me like
you want to know how many pages it will take to print out the worksheet
itself (not how many worksheets are in the workbook). If I am right,
copy/paste the following code into the code window for the worksheet you
want this functionality on (right click the worksheet's tab and select View
Code from the popup menu that appears)....

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Whoops
Application.EnableEvents = False
Range("A1").Value = ExecuteExcel4Macro("GET.DOCUMENT(50)")
Whoops:
Application.EnableEvents = True
End Sub

Rick


"NateBuckley" <(E-Mail Removed)> wrote in message
news:F0A18399-21EB-4124-A69E-(E-Mail Removed)...
> Hello I hope this helps, go to the code in ThisWorkBook.
>
> You can do this by pushing ALT+F11 then right clicking on "ThisWorkBook"
> on
> the left, and left clicking on view code.
>
> Then paste in the following
>
> Private Sub Workbook_Open()
> Sheets("NameOfSheet").Cells(1, 1).Value = Worksheets.Count
> End Sub
>
> When the worksheet opens it'll count the number of worksheets and put this
> value in a specified cell. So in this case if you had a sheet named
> NameOfSheet it would put a number in Row 1, Column A.
>
> Hope this helped.
>
> "msnews" wrote:
>
>> i want to insert the count of total number of pages of a worksheet in a
>> cell
>> of the same worksheet.
>> this should be done automatically using worksheet formula or visual basic
>> code or macro.
>> please help
>>
>>
>>


 
Reply With Quote
 
S N
Guest
Posts: n/a
 
      8th Apr 2008
you have guessed it correctly.
i want to know how many pages will print when i give print command on a particular worksheet
(and not how many worksheets are there in a particular workbook)

actually i want to display the following text on a particular column cells

page x of y (where x is the particular page on which the cell lies and y is the total number of pages that would print)

please help


"Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>I am reading your question differently than Nate did... it looks to me like
> you want to know how many pages it will take to print out the worksheet
> itself (not how many worksheets are in the workbook). If I am right,
> copy/paste the following code into the code window for the worksheet you
> want this functionality on (right click the worksheet's tab and select View
> Code from the popup menu that appears)....
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo Whoops
> Application.EnableEvents = False
> Range("A1").Value = ExecuteExcel4Macro("GET.DOCUMENT(50)")
> Whoops:
> Application.EnableEvents = True
> End Sub
>
> Rick
>
>
> "NateBuckley" <(E-Mail Removed)> wrote in message
> news:F0A18399-21EB-4124-A69E-(E-Mail Removed)...
>> Hello I hope this helps, go to the code in ThisWorkBook.
>>
>> You can do this by pushing ALT+F11 then right clicking on "ThisWorkBook"
>> on
>> the left, and left clicking on view code.
>>
>> Then paste in the following
>>
>> Private Sub Workbook_Open()
>> Sheets("NameOfSheet").Cells(1, 1).Value = Worksheets.Count
>> End Sub
>>
>> When the worksheet opens it'll count the number of worksheets and put this
>> value in a specified cell. So in this case if you had a sheet named
>> NameOfSheet it would put a number in Row 1, Column A.
>>
>> Hope this helped.
>>
>> "msnews" wrote:
>>
>>> i want to insert the count of total number of pages of a worksheet in a
>>> cell
>>> of the same worksheet.
>>> this should be done automatically using worksheet formula or visual basic
>>> code or macro.
>>> please help
>>>
>>>
>>>

>
>

 
Reply With Quote
 
S N
Guest
Posts: n/a
 
      8th Apr 2008
and i dont want to copy the function or code on all worksheets in my
workbooks. i would like to use something like code in a module file.

i would like to have a general code which i can use in all worksheets of my
workbooks

please help.

"Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
>I am reading your question differently than Nate did... it looks to me like
>you want to know how many pages it will take to print out the worksheet
>itself (not how many worksheets are in the workbook). If I am right,
>copy/paste the following code into the code window for the worksheet you
>want this functionality on (right click the worksheet's tab and select View
>Code from the popup menu that appears)....
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo Whoops
> Application.EnableEvents = False
> Range("A1").Value = ExecuteExcel4Macro("GET.DOCUMENT(50)")
> Whoops:
> Application.EnableEvents = True
> End Sub
>
> Rick
>
>
> "NateBuckley" <(E-Mail Removed)> wrote in message
> news:F0A18399-21EB-4124-A69E-(E-Mail Removed)...
>> Hello I hope this helps, go to the code in ThisWorkBook.
>>
>> You can do this by pushing ALT+F11 then right clicking on "ThisWorkBook"
>> on
>> the left, and left clicking on view code.
>>
>> Then paste in the following
>>
>> Private Sub Workbook_Open()
>> Sheets("NameOfSheet").Cells(1, 1).Value = Worksheets.Count
>> End Sub
>>
>> When the worksheet opens it'll count the number of worksheets and put
>> this
>> value in a specified cell. So in this case if you had a sheet named
>> NameOfSheet it would put a number in Row 1, Column A.
>>
>> Hope this helped.
>>
>> "msnews" wrote:
>>
>>> i want to insert the count of total number of pages of a worksheet in a
>>> cell
>>> of the same worksheet.
>>> this should be done automatically using worksheet formula or visual
>>> basic
>>> code or macro.
>>> please help
>>>
>>>
>>>

>
>



 
Reply With Quote
 
NateBuckley
Guest
Posts: n/a
 
      8th Apr 2008
My apologies, I misread what you put.


"S N" wrote:

> you have guessed it correctly.
> i want to know how many pages will print when i give print command on a particular worksheet
> (and not how many worksheets are there in a particular workbook)
>
> actually i want to display the following text on a particular column cells
>
> page x of y (where x is the particular page on which the cell lies and y is the total number of pages that would print)
>
> please help
>
>
> "Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >I am reading your question differently than Nate did... it looks to me like
> > you want to know how many pages it will take to print out the worksheet
> > itself (not how many worksheets are in the workbook). If I am right,
> > copy/paste the following code into the code window for the worksheet you
> > want this functionality on (right click the worksheet's tab and select View
> > Code from the popup menu that appears)....
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > On Error GoTo Whoops
> > Application.EnableEvents = False
> > Range("A1").Value = ExecuteExcel4Macro("GET.DOCUMENT(50)")
> > Whoops:
> > Application.EnableEvents = True
> > End Sub
> >
> > Rick
> >
> >
> > "NateBuckley" <(E-Mail Removed)> wrote in message
> > news:F0A18399-21EB-4124-A69E-(E-Mail Removed)...
> >> Hello I hope this helps, go to the code in ThisWorkBook.
> >>
> >> You can do this by pushing ALT+F11 then right clicking on "ThisWorkBook"
> >> on
> >> the left, and left clicking on view code.
> >>
> >> Then paste in the following
> >>
> >> Private Sub Workbook_Open()
> >> Sheets("NameOfSheet").Cells(1, 1).Value = Worksheets.Count
> >> End Sub
> >>
> >> When the worksheet opens it'll count the number of worksheets and put this
> >> value in a specified cell. So in this case if you had a sheet named
> >> NameOfSheet it would put a number in Row 1, Column A.
> >>
> >> Hope this helped.
> >>
> >> "msnews" wrote:
> >>
> >>> i want to insert the count of total number of pages of a worksheet in a
> >>> cell
> >>> of the same worksheet.
> >>> this should be done automatically using worksheet formula or visual basic
> >>> code or macro.
> >>> please help
> >>>
> >>>
> >>>

> >
> >

 
Reply With Quote
 
S N
Guest
Posts: n/a
 
      11th Apr 2008
actually i am using the value in a cell in the table.
hence i cant use header and footer.
i want to have a function for getting the value.
please help.


"Jean-Yves TFELT" <noSpam@I_Hate_Spam> wrote in message
news:(E-Mail Removed)...
> Hi,
>
>
> Cant you just use the Header or the Footer section where excel can give
> you that automatically ?
>
> Regards
> Jean-Yves
>
> "S N" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> and i dont want to copy the function or code on all worksheets in my
>> workbooks. i would like to use something like code in a module file.
>>
>> i would like to have a general code which i can use in all worksheets of
>> my workbooks
>>
>> please help.
>>
>> "Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote
>> in message news:(E-Mail Removed)...
>>>I am reading your question differently than Nate did... it looks to me
>>>like you want to know how many pages it will take to print out the
>>>worksheet itself (not how many worksheets are in the workbook). If I am
>>>right, copy/paste the following code into the code window for the
>>>worksheet you want this functionality on (right click the worksheet's tab
>>>and select View Code from the popup menu that appears)....
>>>
>>> Private Sub Worksheet_Change(ByVal Target As Range)
>>> On Error GoTo Whoops
>>> Application.EnableEvents = False
>>> Range("A1").Value = ExecuteExcel4Macro("GET.DOCUMENT(50)")
>>> Whoops:
>>> Application.EnableEvents = True
>>> End Sub
>>>
>>> Rick
>>>
>>>
>>> "NateBuckley" <(E-Mail Removed)> wrote in message
>>> news:F0A18399-21EB-4124-A69E-(E-Mail Removed)...
>>>> Hello I hope this helps, go to the code in ThisWorkBook.
>>>>
>>>> You can do this by pushing ALT+F11 then right clicking on
>>>> "ThisWorkBook" on
>>>> the left, and left clicking on view code.
>>>>
>>>> Then paste in the following
>>>>
>>>> Private Sub Workbook_Open()
>>>> Sheets("NameOfSheet").Cells(1, 1).Value = Worksheets.Count
>>>> End Sub
>>>>
>>>> When the worksheet opens it'll count the number of worksheets and put
>>>> this
>>>> value in a specified cell. So in this case if you had a sheet named
>>>> NameOfSheet it would put a number in Row 1, Column A.
>>>>
>>>> Hope this helped.
>>>>
>>>> "msnews" wrote:
>>>>
>>>>> i want to insert the count of total number of pages of a worksheet in
>>>>> a cell
>>>>> of the same worksheet.
>>>>> this should be done automatically using worksheet formula or visual
>>>>> basic
>>>>> code or macro.
>>>>> please help
>>>>>
>>>>>
>>>>>
>>>
>>>

>>
>>

>
>
>



 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      11th Apr 2008
In order for you to be able to put the page number on each page, I guessing
that would mean there are set cells reserved for the page number... what are
those cell addresses?

Rick


"S N" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> actually i am using the value in a cell in the table.
> hence i cant use header and footer.
> i want to have a function for getting the value.
> please help.
>
>
> "Jean-Yves TFELT" <noSpam@I_Hate_Spam> wrote in message
> news:(E-Mail Removed)...
>> Hi,
>>
>>
>> Cant you just use the Header or the Footer section where excel can give
>> you that automatically ?
>>
>> Regards
>> Jean-Yves
>>
>> "S N" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> and i dont want to copy the function or code on all worksheets in my
>>> workbooks. i would like to use something like code in a module file.
>>>
>>> i would like to have a general code which i can use in all worksheets of
>>> my workbooks
>>>
>>> please help.
>>>
>>> "Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote
>>> in message news:(E-Mail Removed)...
>>>>I am reading your question differently than Nate did... it looks to me
>>>>like you want to know how many pages it will take to print out the
>>>>worksheet itself (not how many worksheets are in the workbook). If I am
>>>>right, copy/paste the following code into the code window for the
>>>>worksheet you want this functionality on (right click the worksheet's
>>>>tab and select View Code from the popup menu that appears)....
>>>>
>>>> Private Sub Worksheet_Change(ByVal Target As Range)
>>>> On Error GoTo Whoops
>>>> Application.EnableEvents = False
>>>> Range("A1").Value = ExecuteExcel4Macro("GET.DOCUMENT(50)")
>>>> Whoops:
>>>> Application.EnableEvents = True
>>>> End Sub
>>>>
>>>> Rick
>>>>
>>>>
>>>> "NateBuckley" <(E-Mail Removed)> wrote in message
>>>> news:F0A18399-21EB-4124-A69E-(E-Mail Removed)...
>>>>> Hello I hope this helps, go to the code in ThisWorkBook.
>>>>>
>>>>> You can do this by pushing ALT+F11 then right clicking on
>>>>> "ThisWorkBook" on
>>>>> the left, and left clicking on view code.
>>>>>
>>>>> Then paste in the following
>>>>>
>>>>> Private Sub Workbook_Open()
>>>>> Sheets("NameOfSheet").Cells(1, 1).Value = Worksheets.Count
>>>>> End Sub
>>>>>
>>>>> When the worksheet opens it'll count the number of worksheets and put
>>>>> this
>>>>> value in a specified cell. So in this case if you had a sheet named
>>>>> NameOfSheet it would put a number in Row 1, Column A.
>>>>>
>>>>> Hope this helped.
>>>>>
>>>>> "msnews" wrote:
>>>>>
>>>>>> i want to insert the count of total number of pages of a worksheet in
>>>>>> a cell
>>>>>> of the same worksheet.
>>>>>> this should be done automatically using worksheet formula or visual
>>>>>> basic
>>>>>> code or macro.
>>>>>> please help
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>>

>>
>>
>>

>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Number of pages in worksheet doesn't match Print Preview pages delru Microsoft Excel Misc 2 10th May 2010 10:10 PM
how to count number of pages in worksheet msnews Microsoft Excel Worksheet Functions 7 11th Apr 2008 02:39 PM
how to count number of pages in worksheet msnews Microsoft Excel Programming 7 11th Apr 2008 02:39 PM
how to count the number of pages of a file prince via DotNetMonster.com Microsoft VB .NET 1 6th Jan 2008 01:42 PM
Count number of pages =?Utf-8?B?cm04MQ==?= Microsoft Excel Worksheet Functions 3 9th Jun 2006 05:52 PM


Features
 

Advertising
 

Newsgroups
 


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