Rows to Repeat at Top


April 7, 2008 – 3:51 pm by JP

If you want to programmatically set the "Rows to Repeat At Top" option on the Sheet tab in Excel's Page Setup dialog box, here are two ways to do it.

If you already know what range you want, you could use this code:

VBA:
  1. ActiveSheet.PageSetup.PrintTitleRows = "$1:$1"

This would set row 1 (which would ideally be a list of column headers) to print at the top of every page.

To set this option based on a user selection:

VBA:
  1. ActiveSheet.PageSetup.PrintTitleRows = Selection.Areas(1).Address

This code assumes that you have selected at least one entire row, i.e. select rows 1 through 4 then use the code above to set "Rows to repeat at top" to $1:$4.

HTH,
JP


Share and Enjoy:
  • StumbleUpon
  • Technorati
  • Digg
  • Google
  • del.icio.us
  • MisterWong

Print This Post Print This Post  |  Email This Post Email This Post  |  Permalink  |  Subscribe to this feed Subscribe now!

Filed Under: Excel, VBA
Tags: , ,

This post has 447 views since April 7, 2008 – 3:51 pm.
  1. One Response to “Rows to Repeat at Top”

  2. Excellent tip!! I've always puzzled over how to do this.

    Thanks for another awesome post. I love Excel :)

    By mary on Apr 8, 2008

Post a Comment

To post VBA code in your comment, use [VBA] tags, like this: [VBA]Code goes here[/VBA].





Subscribe without commenting

Keep Reading:

Browse Posts:


« Excel User Conference || UDF to return page headers/footers text »