Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default coding help for headers

One way is to test the sheet index


Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Index 7 Then
With ActiveSheet.PageSetup
.CenterHeader = _
"&""Arial,Bold""Statement of Investment Advisory Services" _
& Chr(10) & "prepared for " & Chr(10) & "&14" &
ActiveSheet.Range("A1").Value _
& "&10" & Chr(10) & "for the three month period
from " & Chr(10) _
& ActiveSheet.Range("B2").Value & Chr(10) &
Chr(10)
End With
End If
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl



"Dixie Folzenlogen" <Dixie wrote in
message ...
I'm not a programmer but have occasionally been able to "piece together"
some
VB code using this forum which has been very helpful. Here's what I'm
trying
to do:
I want to generate page headers on multiple worksheets in one workbook
which
pull in information using cell references. I do not want to have this
particular header for ALL my worksheets. Specifically, the first 7
worksheets should not have a header and the balance should. Using this
forum, I put this in this code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.PageSetup
.CenterHeader = _
"&""Arial,Bold""Statement of Investment Advisory Services" _
& Chr(10) & "prepared for " & Chr(10) & "&14" &
ActiveSheet.Range("A1").Value _
& "&10" & Chr(10) & "for the three month period from " & Chr(10) _
& ActiveSheet.Range("B2").Value & Chr(10) & Chr(10)
End With
End Sub

Unfortunately, this is applied against all worksheets. Can someone tell
me
what I am doing wrong? I would certainly appreciate any help.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default coding help for headers

hi Dixie

Your first worksheet have index 1 and the second = 2 and the ......

If ActiveSheet.Index 7 Then
This will only run the code if the activesheet is in position 8 or higher.

Have you delete the header in all sheets first before you start testing ?



--

Regards Ron de Bruin
http://www.rondebruin.nl



"Dixie Folzenlogen" wrote in
message ...
Thanks Ron. Forgive my ignorance but what is the sheet index? I have
combined several workbooks and even tho one of my worksheets is in
"position
1" in the current workbook, it must have retained it's old "index" because
the header is still showing up. Suggestions?

"Ron de Bruin" wrote:

One way is to test the sheet index


Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Index 7 Then
With ActiveSheet.PageSetup
.CenterHeader = _
"&""Arial,Bold""Statement of Investment Advisory Services" _
& Chr(10) & "prepared for " & Chr(10) & "&14" &
ActiveSheet.Range("A1").Value _
& "&10" & Chr(10) & "for the three month period
from " & Chr(10) _
& ActiveSheet.Range("B2").Value & Chr(10) &
Chr(10)
End With
End If
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl



"Dixie Folzenlogen" <Dixie wrote
in
message ...
I'm not a programmer but have occasionally been able to "piece
together"
some
VB code using this forum which has been very helpful. Here's what I'm
trying
to do:
I want to generate page headers on multiple worksheets in one workbook
which
pull in information using cell references. I do not want to have this
particular header for ALL my worksheets. Specifically, the first 7
worksheets should not have a header and the balance should. Using this
forum, I put this in this code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.PageSetup
.CenterHeader = _
"&""Arial,Bold""Statement of Investment Advisory Services" _
& Chr(10) & "prepared for " & Chr(10) & "&14" &
ActiveSheet.Range("A1").Value _
& "&10" & Chr(10) & "for the three month period from " & Chr(10)
_
& ActiveSheet.Range("B2").Value & Chr(10) & Chr(10)
End With
End Sub

Unfortunately, this is applied against all worksheets. Can someone
tell
me
what I am doing wrong? I would certainly appreciate any 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
lookup using column headers and row headers Memphus01 Excel Discussion (Misc queries) 1 April 13th 09 04:57 PM
Macro to insert headers..need coding help [email protected] Excel Programming 9 October 11th 06 07:34 PM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM
Could someone help me with some coding stevie Excel Programming 1 April 1st 04 08:40 AM


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