Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is it that maybe he is not seeing the 'OK to use VB' prompt at the top
of the page when he opens the workbook? On Wed, 2 Nov 2011 10:34:10 -0700, "Jim Cone" wrote: Garry's sub should work for you... '--- Private Sub Workbook_BeforePrint(Cancel As Boolean) ActiveSheet.PageSetup.RightHeader = _ Sheets("revisiondate").Range("B2").Value End Sub '--- Take the line... ActiveSheet.PageSetup.RightHeader = Sheets("revisiondate").Range("B2").Value and place it in a standard module and run it. It should place the value from B2 in the header. If that works, then let me ask this question again... What module is your code in? There are code modules behind each sheet in a workbook. There is a code module for each userform. There are standard and class modules that the code writer can add. There is a "ThisWorkbook" code module. Your code belongs in the ThisWorkbook module. '-- Jim Cone Portland, Oregon USA . http://www.contextures.com/excel-sort-addin.html . (editorial review of Special Sort excel add-in (30 ways to sort) "doki60" wrote in message ... GS wrote on 11/02/2011 11:01 ET : 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 All good ideas but still no change. I suspect something is preventing the routine from running btu I can't figure out what it would be. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
On Error Resume Next not working (2010) | Excel Programming | |||
VBA: Insert Page Breaks code is not working in Excel 2010 | Excel Programming | |||
year 2010 not working in IF | Excel Discussion (Misc queries) | |||
Excel VBA script not fully working... help! | Excel Programming | |||
Excel VB Script Not Working in Explorer | Excel Programming |