+ Reply to Thread
Results 1 to 7 of 7

Worksheet Macro to add page numbers

  1. #1
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Worksheet Macro to add page numbers

    I tried to modify Martin's macro code here (http://www.excelforum.com/excel-misc...ge-titles.html) to work as a BeforePrint event but it doesn't work.
    Here's my code.
    Please Login or Register  to view this content.
    Without the "Cancel = True line, it prints twice but always with a 2 in the first line (it's a 2 page document). With the Cancel = True line, it doesn't print at all. Thoughts?

    ChemistB

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Step through the code and what happens?

    Specifically, what is the value of TotalPages?

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Which brings me to a question I've been wanting to ask.

    I can only step through (F8) code in a module. When I try it in a worksheet or Thisworkbook, nothing happens. How do I step through code in thisworkbook? Excel 2000

    ChemistB

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Play with it in a normal module.

    Not sure what your after as you don't actual say (least I don't think so).
    If you want to print 3 pages and have the cell value hold the page number you could try

    Please Login or Register  to view this content.
    Maybe some useful links for others
    http://www.ozgrid.com/Excel/excel-page-breaks.htm
    http://www.rondebruin.nl/print.htm#not

    VBA Noob
    Last edited by VBA Noob; 08-29-2008 at 05:05 PM.
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    hi ChemistB

    I never use Excel4 macros, use the hPagebreak
    Please Login or Register  to view this content.
    Last edited by royUK; 08-29-2008 at 05:03 PM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Quote Originally Posted by Chemist
    How do I step through code in thisworkbook?
    There or anyplace else, put the cursor in an executable line of code (i.e., not, e.g, a Dim statement), and hit F9 to add a breakpoint. Then trigger the code in the normal fashion, and step through the code after it breaks.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Okay, I have a lot to look through today. Thanks again to all of you. You're great!

    ChemistB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. assign macro to checkbox placed on worksheet
    By vandanavai in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-23-2007, 03:09 PM
  2. Macro reference change when worksheet renamed ???
    By Southernw2002 in forum Excel General
    Replies: 5
    Last Post: 11-12-2007, 07:24 AM
  3. not having a macro open the worksheet in which it was written
    By johndough185 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-13-2007, 11:17 AM
  4. macro to work for variable number of rows
    By incognito in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-18-2007, 08:48 PM
  5. Identify active worksheet in macro
    By mlk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-12-2007, 09:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1