Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Header concern

Hello

I've scanned several posts, but can't quite find a solution to my problem.

I often need to print a report (worksheet PrntRpt) with a left header that
gets its value from another worksheet (Master). Here's my problem - the
header has 3 lines that get their values from cells A1, A2, A3 of worksheet
Master. I can manually enter this as a 3 line custom header , but I'd
like to do it programatically.

Any ideas?

Much thanks
Brian


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Header concern


Hi Brian,

I'm assuming from your question that you know some macro basics.
If you are already printing from a button incorporate the following
into your existing code:

Dim CustomLeftHeader As String
CustomLeftHeader = Worksheets("Master").Range("a1") & Chr(13) _
& Worksheets("Master").Range("a2") & Chr(13) &
Worksheets("Master").Range("a3")
With Worksheets("PrntRpt").PageSetup
..LeftHeader = CustomLeftHeader
End With


Or if you/users will just be printing using Excel's normal methods (eg
[ctrl + p], file - print) enter this code into your ThisWorkbook code
sheet:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim CustomLeftHeader As String
If ActiveSheet.Name = "PrntRpt" Then
CustomLeftHeader = Worksheets("Master").Range("a1") & Chr(13) _
& Worksheets("Master").Range("a2") & Chr(13) &
Worksheets("Master").Range("a3")
With Worksheets("PrntRpt").PageSetup
..LeftHeader = CustomLeftHeader
End With
Else
End If
End Sub


hth
Rob Brockett
NZ
Always learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=521424

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Header concern

Thank you, Rob
It needed a dot before the LeftHeader, but otherwise works fine.
Brian

"broro183" wrote in
message ...

Hi Brian,

I'm assuming from your question that you know some macro basics.
If you are already printing from a button incorporate the following
into your existing code:

Dim CustomLeftHeader As String
CustomLeftHeader = Worksheets("Master").Range("a1") & Chr(13) _
& Worksheets("Master").Range("a2") & Chr(13) &
Worksheets("Master").Range("a3")
With Worksheets("PrntRpt").PageSetup
LeftHeader = CustomLeftHeader
End With


Or if you/users will just be printing using Excel's normal methods (eg
[ctrl + p], file - print) enter this code into your ThisWorkbook code
sheet:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim CustomLeftHeader As String
If ActiveSheet.Name = "PrntRpt" Then
CustomLeftHeader = Worksheets("Master").Range("a1") & Chr(13) _
& Worksheets("Master").Range("a2") & Chr(13) &
Worksheets("Master").Range("a3")
With Worksheets("PrntRpt").PageSetup
LeftHeader = CustomLeftHeader
End With
Else
End If
End Sub


hth
Rob Brockett
NZ
Always learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile:
http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=521424



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Header concern


Hi Brian,

Thanks for the feedback :-)

It's strange about the "dot before leftheader" as I can see it in my
original post but not in your quoted version. Oh well, problem solved
now.

Rob Brockett
NZ
Alweays learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=521424

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
Excel-Header-My Company Name won't work in Header (AT&T) & Time June K Excel Discussion (Misc queries) 2 April 10th 06 08:36 PM
Page Header concern Bri Excel Worksheet Functions 3 January 30th 06 03:28 PM
sorting concern Giselle Excel Worksheet Functions 2 January 27th 06 06:08 PM
hidden column concern Bri Excel Worksheet Functions 3 January 23rd 06 04:26 AM
Toggle Button Updating Concern Jim Thomlinson[_3_] Excel Programming 3 April 14th 05 01:42 AM


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