View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default VB Script not working in Excel 2010

try...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightHeader = _
Sheets("revisiondate").Range("B2").Value
End Sub

Optionally, you could assign a name to the cell on each sheet that
contains this date. Obviously, the defined name will have to have local
scope to be able to use the same name on every sheet. If there's no
place on each sheet for this date and it's confined to sheet
"revisiondate" then just select that cell and type "RevisionDate" into
the Namebox left side of the Formula Bar and press the Enter key. Now
you can just refer to it in VBA as follows:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightHeader = Range("RevisionDate").Value
End Sub

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc