Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default ADD CELL TO RIGHT HEADER

Not really tested, but something like this. You should add error handling
e.g. maybe there is no data after the last HPagebreak
Also, deal with situations where VPageBreaks may be included.

Private Sub CommandButton1_Click()
Dim TopCell As Range
Dim PageCount As Long

With ActiveSheet
Set TopCell = .Range("A2")

For PageCount = 1 To .HPageBreaks.Count
'Assumes values in column A; otherwise adjust column offset value
.PageSetup.RightHeader = TopCell.Value & " - " &
..HPageBreaks(PageCount).Location.Offset(-1, 0).Value
Debug.Print .PageSetup.RightHeader
Set TopCell = .HPageBreaks(PageCount).Location
.PrintOut PageCount, PageCount
Next

'Get the last page data
.PageSetup.RightHeader = TopCell.Value & " - " &
Range("A2").End(xlDown).Value
Debug.Print .PageSetup.RightHeader
.PrintOut PageCount + 1, PageCount + 1

End With

End Sub

NickHK

wrote in message
oups.com...
I have a sheet named Inventory that is 60+ print pages long. I have
row A1 being repeated on every page. Starting with column A2 down I
have my product codes. What I need is a right header that will consist
of the first and last product code on every page with a - in between.
Can someone make me a macros that will do this.



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
Cell Value in Header / Not Using VBA Gojavid New Users to Excel 7 April 23rd 23 07:44 PM
Header as cell value michaelberrier Excel Discussion (Misc queries) 3 May 31st 07 11:24 PM
ADD CELL TO RIGHT HEADER Jim Jackson Excel Programming 0 November 14th 06 06:39 PM
Populating Last Saved Date in Cell AND also update that same cell in Header o0o_Bigs_o0o Excel Discussion (Misc queries) 2 July 4th 06 12:56 PM
Excel: want header cell sizes to differ from the other sheet cell. mayrl Excel Discussion (Misc queries) 0 January 18th 06 06:41 PM


All times are GMT +1. The time now is 07:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"