Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro to set header

I have a file with about 50 different sheets (Names),
I want to print them all, and need to have a header for every sheet, which
is the same name of the TAB, could somebody help me to get a macro to set
the header automatically on every sheet.

Thanks in advance for your help


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Macro to set header

Hi there,

Mabye you could make use of something like this ...

sub SetAllHeaders()
dim ws as worksheet
for each ws in thisworkbook.worksheets '*
ws.pagesetup.centerheader = ws.name
next ws
end sub

I'm guessing that you don't need any special formats of any kind for this
and you want it in the center.

*Assumes you ARE inserting this code into the workbook in which you will
perform the code. If not, change "thisworkbook" with "activeworkbook" and
ensure the code is run on the workbook that is active (the desired
workbook).

--
Regards,
Zack Barresse, aka firefytr


"FGOMEZ" wrote in message
...
I have a file with about 50 different sheets (Names),
I want to print them all, and need to have a header for every sheet, which
is the same name of the TAB, could somebody help me to get a macro to set
the header automatically on every sheet.

Thanks in advance for your help




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to set header


For Each sh In Activeworkbook.Worksheets
with sh
.Pagesetup.LeftHeader = sh.name
.printout
End With
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"FGOMEZ" wrote in message
...
I have a file with about 50 different sheets (Names),
I want to print them all, and need to have a header for every sheet, which
is the same name of the TAB, could somebody help me to get a macro to set
the header automatically on every sheet.

Thanks in advance for your help




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Macro to set header

Also note that this usually takes a while to loop through and change the
pagesetup of Excel worksheets. (Drives me crazy) So 50 sheets may take you
a while. If you want to know how far along you are, change your code to
something like this ...

sub SetAllHeaders()
dim ws as worksheet, lngWs as long
lngWs = thisworkbook.worksheets.count
for each ws in thisworkbook.worksheets '*
application.statusbar = "Working on " & ws.index & " of " & _
lngWs & " : " & format(ws.index / lngWs, "Percent")
ws.pagesetup.centerheader = ws.name
ws.printout '**
next ws
application.statusbar = false
end sub

You must remember to set the statusbar to False when done.
** Added; forgot in last post. Sorry. :(

--
Regards,
Zack Barresse, aka firefytr


"FGOMEZ" wrote in message
...
I have a file with about 50 different sheets (Names),
I want to print them all, and need to have a header for every sheet, which
is the same name of the TAB, could somebody help me to get a macro to set
the header automatically on every sheet.

Thanks in advance for your help




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
Building a Header Macro Jonathan Excel Discussion (Misc queries) 0 April 17th 09 06:00 PM
Macro for Custom Header Le Jurassien Excel Discussion (Misc queries) 1 January 22nd 07 06:27 PM
Custom Header Macro Le Jurassien Excel Discussion (Misc queries) 1 January 10th 07 11:16 PM
Header and Footer Macro dhuang via OfficeKB.com Excel Discussion (Misc queries) 1 October 31st 05 04:14 PM
Macro with a different Header for each Sheet Dragos Excel Discussion (Misc queries) 2 September 15th 05 07:32 AM


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

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"