ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Print multiple pages with different name. (https://www.excelbanter.com/excel-discussion-misc-queries/41202-print-multiple-pages-different-name.html)

Annepaws

Print multiple pages with different name.
 
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.

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

Annepaws wrote:

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.


--

Dave Peterson


All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com