Results 1 to 4 of 4

Return Relative Reference Value based on Page Break

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    Excel 365
    Posts
    129

    Return Relative Reference Value based on Page Break

    Hello Again,

    I've got the following code that creates a page break for every change in a defined column (starting after row 3 to accomodate my table header).

    I repeat the header on each page through Print Tiles. My goal would be to be able to have the Row above the repeated tiles reference the new changed value.

    Dim BreakColumn As String
    BreakColumn = InputBox( _
    "Type in the Column of the Changing Data to Insert Page Break", _
    "Type the Column Letter here")
           
            
            
         Dim lngRowNumber As Long
         Dim strPreviousValue As String
         With ActiveSheet
              strPreviousValue = .Cells(3, BreakColumn).Value '3 is the starting row value
              For lngRowNumber = 3 To .Cells(.Rows.Count, BreakColumn).End(xlUp).Row '3 is the starting row value.  it ignores changes before this.
                   If .Cells(lngRowNumber, BreakColumn).Value <> strPreviousValue Then
                        .HPageBreaks.Add before:=.Cells(lngRowNumber, BreakColumn)
                        strPreviousValue = .Cells(lngRowNumber, BreakColumn).Value
                   End If
              Next lngRowNumber
              .HPageBreaks.Add before:=.Cells(lngRowNumber, BreakColumn)
         End With
    
    
    
    
    'Print Header on Each Page
    Worksheets("Rosters").Activate
    ActiveSheet.PageSetup.PrintTitleRows = ActiveSheet.Rows("$1:$2").Address
    ActiveSheet.PageSetup.PrintTitleColumns = _
     ActiveSheet.Columns("B:F").Address
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Move Page Break 1 cell up if bullet-point is in on the page break.
    By saudi_red_neck in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-06-2019, 10:24 AM
  2. Return relative row with R1C1 reference style
    By esbencito in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-07-2018, 12:22 PM
  3. Match then Return Relative Reference that Also Matches
    By rjj920 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-17-2018, 06:50 PM
  4. Find First match value and add page break, findnext value and add page break
    By dwx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-20-2013, 12:58 PM
  5. Heading based on page break
    By scottydogg84 in forum Excel General
    Replies: 0
    Last Post: 09-28-2011, 10:26 AM
  6. [SOLVED] Page Break based on Dates
    By Dan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2005, 04:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1