Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need the first row in an Excel spreadsheet to print as the header on all pages.

share|improve this question

migrated from stackoverflow.com May 23 '11 at 20:13

This question came from our site for professional and enthusiast programmers.

6 Answers 6

up vote 12 down vote accepted

Go to file->Page Setup and choose the sheet tab. There is an option 'rows to repeat at top'.

share|improve this answer

also programatically (at least in c#) it's to the effect of:

[excel sheet].PageSetup.PrintTitleRows = "$[firstrow]$[lastrow]";

I would expect other languages to handle it similarly though, being that it's a com interface.

share|improve this answer
    
This solution did not work.$[1]$[2] failed at compile time. –  Anonymous Mar 9 '11 at 11:18
    
This will not work as it is now, the $[firstrow]$[lastrow] was just a reference to the absolute locations in excel of the rows you want to set as a header. If I remember correctly, the right side of the equation is set to an excel range. –  Anonymous Mar 16 '11 at 0:46

The old-fashioned way to do it is to define the name "Print_Titles" to be the rows you want printed at the top. Select the rows you want as a header, click in the text-edit box to the left of the formula bar, type "Print_Titles" and hit Enter. Defining the name via the "Define Names" dialog or programatically works fine too, but I don't know where they hid the dialog box in the 2007 UI...

share|improve this answer
    
"Page Layout" > Print Titles (it's in the "Page Setup" group, 2nd from the left) –  Chloraphil May 15 '09 at 17:29

In MS Excel 2007, go over to the Page Layout tab, the first section of that tab is titled "Themes", the second section is titles "Page Setup" the last option there is "Print Title" click it.

A dialog box will appear, simple click on the left column number 1 or your title line and the formula will auto fill. You have selected it and now "print".

share|improve this answer

Here is a step by step description of how to add header rows.

  • Start by selecting the page layout tab and then open the Page Layout dialog box.
  • On the Sheet tab of the Page Setup dialog box, click on the rows to repeat at top.
  • Clicking on the row you want to appear at the top of each page will populate the Page Setup – Rows to repeat at top dialog box. When done return to the Page Setup dialog box by hitting the enter key.
  • Select the OK button to complete the setup.
  • Now whenever you print preview or print your worksheet, the row you selected will be repeated at the top of each page.
share|improve this answer

The problem is the missing colon(:) between rows to repeat at top. You can even try this by viewing it as you set it manually within Excel(any version)

Excel.Application xlApp ;
Excel.Workbook xlWorkBook ;
Excel.Worksheet xlWorkSheet ;
object misValue = System.Reflection.Missing.Value;

xlApp = new Excel.Application(); //Start Excel and get Application object.
xlApp.Visible = true;
xlWorkBook = (Excel.Workbook)(xlApp.Workbooks.Add(misValue));
xlWorkSheet = (Excel.Worksheet)xlWorkBook.ActiveSheet;
xlWorkSheet.PageSetup.PrintTitleRows = "$1:$1"; // Rows to repeat at top of Excel Page Setup
xlWorkSheet.PageSetup.PrintTitleColumns = "$A:$B"; // Columns to repeat at left of Excel Page Setup
share|improve this answer
1  
Can you please explain what this code does and where he should put it? (If this should be VBA code, then there are several typos/errors) –  nixda Sep 25 '13 at 17:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.