• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Macro to customize Right Header

kimkiko

New Member
Hi! :-)


I have spent the last few days trying to make a macro in vba to customize the right header, in a excel sheet with multiple pages, but without much success. :-(


I need some help to do the following macro:


"In first right header page": N. M001 to M002

"In second right header page": N. M003 to M004

"In third right header page": N. M005 to M006

"In fourth right header page": N. M007 to M008

"In fifth right header page": N. M009 to M010

"In sixth right header page": N. M011 to M012

"In seventh right header page": N. M013 to M014

"In eighth right header page": N. M015 to M016

..

..

..

to the last page


Thanks in advance
 
Hi Kim ,


Can you write it on your own ? You need to do the following :


1. Set the print area manually.


2. Note down the number of printed pages that will result ; let us say it is 22.


3. Use a FOR ... NEXT loop in your macro , to print each page , one after another ; this can be done by using the Range.Printout method , specifying the page number in the first and second parameters.


4. Prior to issuing the Range.Printout statement , use the statement :


Worksheets("Sheet Name").PageSetup.RightHeader = "N. M001 to M002"


Of course , since you want this text to vary , you will have to ensure that the text is changed within the loop.


In case you are facing problems , let me know , and I can post the complete macro tomorrow ; it would help if you could upload your workbook , after erasing all data , retaining the print area and the printer settings such as lines per page , margins etc.


Narayan
 
Back
Top