Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Insert cellS(!) text into header for printing

Hello
I copied the basic listing and tryed to have it working for all the headers
but it works only for the first one. What do I wrong?
Thank you for helping

Sub InsertCellsDataInHeader()

With ActiveSheet
..PageSetup.LeftHeader = .Range("A1").Text
..PageSetup.CenterHeader = .Range("A2").Text
..PageSetup.RightHeader = .Range("A3").Text
End With

End Sub

--
dilettante
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Insert cellS(!) text into header for printing

I assume you run this code before you print? If so it will only act on the
currently active sheet, other sheets will not be changed as you may expect?

If this is the problem, you might try.....

Sub InsertCellsDataInHeader()
Dim wS as Worksheet
For each wS in Activeworkbook.Worksheets
With wS
.PageSetup.LeftHeader = .Range("A1").Text
.PageSetup.CenterHeader = .Range("A2").Text
.PageSetup.RightHeader = .Range("A3").Text
End With
Next
End Sub

This will put the values A1, A2 and A3 from each sheet into the headers for
that sheet, but you may wish to have the same values, say from sheet1
appearing in every worksheet. In wich case use

Sub InsertCellsDataInHeader()
Dim wS as Worksheet
For each wS in Activeworkbook.Worksheets
With wS
.PageSetup.LeftHeader = Sheets("Sheet1").Range("A1").Text
.PageSetup.CenterHeader = Sheets("Sheet1").Range("A2").Text
.PageSetup.RightHeader = Sheets("Sheet1").Range("A3").Text
End With
Next
End Sub
--
Cheers
Nigel



"dilettante" wrote in message
...
Hello
I copied the basic listing and tryed to have it working for all the
headers
but it works only for the first one. What do I wrong?
Thank you for helping

Sub InsertCellsDataInHeader()

With ActiveSheet
.PageSetup.LeftHeader = .Range("A1").Text
.PageSetup.CenterHeader = .Range("A2").Text
.PageSetup.RightHeader = .Range("A3").Text
End With

End Sub

--
dilettante



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Insert cellS(!) text into header for printing

Hello,
Thank you for helping.
The first lkisting works well.
The second one (which is more useful then the first) have a Run Time Error 9
coming out when the procedure reaches the expression
".PageSetup.LeftHeader = Sheets("Sheet1").Range("A1").Text ".
I will try to understand the reason why.
Best regards

--
dilettante


"dilettante" wrote:

Hello
I copied the basic listing and tryed to have it working for all the headers
but it works only for the first one. What do I wrong?
Thank you for helping

Sub InsertCellsDataInHeader()

With ActiveSheet
.PageSetup.LeftHeader = .Range("A1").Text
.PageSetup.CenterHeader = .Range("A2").Text
.PageSetup.RightHeader = .Range("A3").Text
End With

End Sub

--
dilettante

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Insert cellS(!) text into header for printing

Nigel,
now I have it: it works perfectly.
Thank you!
Regards
--
dilettante


"dilettante" wrote:

Hello,
Thank you for helping.
The first lkisting works well.
The second one (which is more useful then the first) have a Run Time Error 9
coming out when the procedure reaches the expression
".PageSetup.LeftHeader = Sheets("Sheet1").Range("A1").Text ".
I will try to understand the reason why.
Best regards

--
dilettante


"dilettante" wrote:

Hello
I copied the basic listing and tryed to have it working for all the headers
but it works only for the first one. What do I wrong?
Thank you for helping

Sub InsertCellsDataInHeader()

With ActiveSheet
.PageSetup.LeftHeader = .Range("A1").Text
.PageSetup.CenterHeader = .Range("A2").Text
.PageSetup.RightHeader = .Range("A3").Text
End With

End Sub

--
dilettante

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Insert cellS(!) text into header for printing

You're welcome. Glad it works OK now

--
Cheers
Nigel



"dilettante" wrote in message
...
Nigel,
now I have it: it works perfectly.
Thank you!
Regards
--
dilettante


"dilettante" wrote:

Hello,
Thank you for helping.
The first lkisting works well.
The second one (which is more useful then the first) have a Run Time
Error 9
coming out when the procedure reaches the expression
".PageSetup.LeftHeader = Sheets("Sheet1").Range("A1").Text ".
I will try to understand the reason why.
Best regards

--
dilettante


"dilettante" wrote:

Hello
I copied the basic listing and tryed to have it working for all the
headers
but it works only for the first one. What do I wrong?
Thank you for helping

Sub InsertCellsDataInHeader()

With ActiveSheet
.PageSetup.LeftHeader = .Range("A1").Text
.PageSetup.CenterHeader = .Range("A2").Text
.PageSetup.RightHeader = .Range("A3").Text
End With

End Sub

--
dilettante



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
Maximum Text in Cells for Printing Marie Excel Discussion (Misc queries) 1 May 10th 10 02:26 PM
How to insert Header will full text across page Janet A. Thompson Excel Discussion (Misc queries) 0 January 12th 10 02:14 PM
Displaying & Printing cells with lotsa text JohnTheTemp Excel Discussion (Misc queries) 2 September 30th 09 11:21 PM
Slanted Text in header cells Christine Excel Discussion (Misc queries) 4 February 16th 05 06:09 AM
Insert cell/format/text/fontsize and auto insert into header? Unfurltheflag Excel Programming 2 November 3rd 04 05:39 PM


All times are GMT +1. The time now is 07:07 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"