PC Review


Reply
Thread Tools Rate Thread

ADD CELL TO RIGHT HEADER

 
 
genesisoxygen@gmail.com
Guest
Posts: n/a
 
      14th Nov 2006
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 With Quote
 
 
 
 
=?Utf-8?B?SmltIEphY2tzb24=?=
Guest
Posts: n/a
 
      14th Nov 2006
Here is one solution if I understood your question correctly.

Sub test()
Dim rng As Range
With Cells
Set rng = .Range(.Cells(2, 2), .Cells(2, 2)).End(xlDown)
rng.Activate
x = ActiveCell
Range("B1") = Range("B2") & " - " & x
End With
End Sub
--
Best wishes,

Jim


"(E-Mail Removed)" wrote:

> 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 With Quote
 
NickHK
Guest
Posts: n/a
 
      15th Nov 2006
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

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell Value in Header / Not Using VBA Gojavid Microsoft Excel New Users 6 16th Aug 2007 05:22 PM
Header as cell value michaelberrier Microsoft Excel Misc 3 31st May 2007 11:24 PM
Populating Last Saved Date in Cell AND also update that same cell in Header o0o_Bigs_o0o Microsoft Excel Misc 2 4th Jul 2006 12:56 PM
Excel: want header cell sizes to differ from the other sheet cell. =?Utf-8?B?bWF5cmw=?= Microsoft Excel Misc 0 18th Jan 2006 06:41 PM
Cell in Header ? Ronbmy Microsoft Excel Programming 4 19th Jun 2005 02:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:32 PM.