PDA

View Full Version : Solved: Print Reports Based on Cell Value



Anne Troy
10-20-2008, 07:46 AM
With the attached workbook, on "Print", I would like Sheet2!B2 to go through each name in the range named "paynames" and print one copy of Sheet2 for each name. I would then like the workbook to save and close itself.

I would also like to be able, before distributing the workbook, to hide the sheet tabs, gridlines, and row and column headings.

Once I have this code, I'm going to try to adapt it to a few more forms, or I may add more worksheets to this workbook, that will simply print one of each normally.

Thanks in advance!!!

Bob Phillips
10-20-2008, 08:10 AM
Public Function PrintAll()
Dim cell As Range

With Worksheets("PrintTimesheets")

For Each cell In Range(.Range("D4"), .Range("D4").End(xlDown))

Worksheets("Sheet2").Range("B1").Value = cell.Value
Worksheets("Sheet2").PrintOut
Next cell
End With

Worksheets("Sheet2").Select
With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With

Worksheets("PrintTimesheets").Select
With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With

ThisWorkbook.Save
ThisWorkbook.Close
End Function

Anne Troy
10-20-2008, 09:07 AM
I love you. :)
Perfect-a-mundo!!!