Print multiple pages with different name.

G

Guest

I have set up a timesheet in excel that I would like to be able to print with
each employees name on it. Is there a way of doing this without creating a
sheet for each employee.
 
D

Dave Peterson

Say you put the names of the employees on Sheet2 (a1:Axxx). And you want to
print Sheet1 (and the names go into C1). Then you could run a little macro to
print:

Option Explicit
Sub testme01()

Dim myCell As Range
Dim myNamesRng As Range
Dim myHeaderCell As Range

With Worksheets("sheet2")
Set myNamesRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

With Worksheets("sheet1")
Set myHeaderCell = .Range("C1")

For Each myCell In myNamesRng.Cells
myHeaderCell.Value = myCell.Value
.PrintOut preview:=True
Next myCell

myHeaderCell.ClearContents

End With

End Sub

(I used preview:=true to save paper while testing.)

If you're new to macros, you may want to read David's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top