Consulting

Results 1 to 3 of 3

Thread: Solved: Print Reports Based on Cell Value

  1. #1
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location

    Solved: Print Reports Based on Cell Value

    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!!!
    ~Anne Troy

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    I love you.
    Perfect-a-mundo!!!
    ~Anne Troy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •