Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Does anyone know the code to put a number in the right header...

You are already 50% there.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
ActiveSheet.Range("K1").Value = ActiveSheet.Range("K1").Value + 1
ActiveSheet.PageSetup.RightHeader = ActiveSheet.Range("K1").Value
End If
End Sub

--
Gary''s Student - gsnu200737


"Jennifer-Houston, TX" wrote:

Does anyone know the code to put a number in the right header and have the
number change everytime you print? This number has nothing to do with the
worksheet itself, it is a totally different number.

This is what I am using to do the regular printing in the spreadsheet and
would like it to be changed for the right header only no cell reference:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
ActiveSheet.Range("K1").Value = ActiveSheet.Range("K1").Value + 1
End If
End Sub

Thanks sorry for the double post but I haven't received an answer to help me.
Jennifer

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Does anyone know the code to put a number in the right header.

O.K.


This macro will create a custom property that will hold the counter:

Sub firstone()
Dim dp As DocumentProperties
Set dp = ThisWorkbook.CustomDocumentProperties
dp.Add Name:="jenny", _
LinkToContent:=False, _
Type:=msoPropertyTypeNumber, _
Value:=1
End Sub

and then the print sub:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
n = ThisWorkbook.CustomDocumentProperties("jenny").Val ue
n = n + 1
ActiveSheet.PageSetup.RightHeader = n
ThisWorkbook.CustomDocumentProperties("jenny").Val ue = n
End If
End Sub

This does not use a cell, it uses this "special" property or variable that
is associated with the file.
--
Gary''s Student - gsnu200737


"Jennifer-Houston, TX" wrote:

Thanks for the help but I don't want it to use any cells from the worksheet.
I want it to be a seperate number all together.
Thanks Jennifer

"Gary''s Student" wrote:

You are already 50% there.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
ActiveSheet.Range("K1").Value = ActiveSheet.Range("K1").Value + 1
ActiveSheet.PageSetup.RightHeader = ActiveSheet.Range("K1").Value
End If
End Sub

--
Gary''s Student - gsnu200737


"Jennifer-Houston, TX" wrote:

Does anyone know the code to put a number in the right header and have the
number change everytime you print? This number has nothing to do with the
worksheet itself, it is a totally different number.

This is what I am using to do the regular printing in the spreadsheet and
would like it to be changed for the right header only no cell reference:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
ActiveSheet.Range("K1").Value = ActiveSheet.Range("K1").Value + 1
End If
End Sub

Thanks sorry for the double post but I haven't received an answer to help me.
Jennifer

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Does anyone know the code to put a number in the right header.

Thanks for the help but I don't want it to use any cells from the worksheet.
I want it to be a seperate number all together.
Thanks Jennifer

"Gary''s Student" wrote:

You are already 50% there.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
ActiveSheet.Range("K1").Value = ActiveSheet.Range("K1").Value + 1
ActiveSheet.PageSetup.RightHeader = ActiveSheet.Range("K1").Value
End If
End Sub

--
Gary''s Student - gsnu200737


"Jennifer-Houston, TX" wrote:

Does anyone know the code to put a number in the right header and have the
number change everytime you print? This number has nothing to do with the
worksheet itself, it is a totally different number.

This is what I am using to do the regular printing in the spreadsheet and
would like it to be changed for the right header only no cell reference:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
ActiveSheet.Range("K1").Value = ActiveSheet.Range("K1").Value + 1
End If
End Sub

Thanks sorry for the double post but I haven't received an answer to help me.
Jennifer

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
what code pulls in contents of a cell in an Excel header/footer? Ronnyk Excel Discussion (Misc queries) 3 September 13th 07 08:18 PM
Does anyone know the code to put a number in the right header and. Jennifer-Houston, TX[_2_] Excel Discussion (Misc queries) 4 August 17th 07 02:12 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
VBA Code to Add the same header from my first sheet into 20 sheets [email protected] Excel Worksheet Functions 4 December 15th 06 02:13 AM
How do i number pages in a header consequently JRD Excel Worksheet Functions 2 January 23rd 05 05:07 PM


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