Results 1 to 2 of 2

print macro help

Threaded View

  1. #1
    Registered User
    Join Date
    07-05-2011
    Location
    Cincinnati, OH
    MS-Off Ver
    Mac Excell 2011
    Posts
    10

    Post print macro help

    What I am trying to do simply stated is push the print button and have sheet2 print then whosmynursedays print then whosmynurseevenings print then according to macro add one day and print sheet2 then whosmynursedays and the whomynurse evenings and so on for the number of days indicated in N2. This has to print in this order as whomynurse sheets are getting their data from sheet2 which is getting its data from sheet1. Sheet2 is the reference sheet for the whosmynursedays sheets it has to change from sheet2 first then print both of the others before adding a day and starting over. Attached is the current macro. Please someone help. I have a basic knowledge of excel and as you can see from the macro the person who made the original for me was kind enough to explain but I have been unsuccessful in adapting it to meet my new needs. Thank you for looking. I can send the file if you need.

    tourofdutyrecordshosmynursetestsendable(1).xlsm
    Sub PrintDoc()
    
    'the data in sheet will alter as the date in A1 is altered
    'as per the formulas in the sheet
    'Use NumDays as our name for a variable to determine how many day plans to print
    'excel dates display as date but are stored as numbers.  add 1 to a date number and you get the next day
    
    'eg see the formulas I have in sheet1 C1, and have dragged thro to AD1  Now if you put a date just in B1
    ' you get the rest following on
    
    'code uses a 'For / Next' loop to do the print several times
    'Our Start date = date in N1 so first time in loop we want N1 + nothing
    'thereafter we want to add 1 each time
    'so we will add NumDays from NumDays = 0 to NumDays = 1 less than our number of days entered in N2
    
    With ActiveSheet  'unles otherwise specified references to ranges etc will be assumed for this sheet
    
        For NumDays = 0 To .Range("N2") - 1   'set the range of the loop counter NumDays
                                              'unless otherwise stated the step or increment will be 1
            .Range("A1").Value = .Range("N1") + NumDays  'set A1 to our start date + our counter value that adds the additional days
            If .Range("N3") = "Yes" Then  ' check if we want to preview the print or not
                ActiveWindow.SelectedSheets.PrintPreview  'if yes then print sheet with preview
                GoTo NextNum  'then goto the label NextNum so as to skip the print direct line
            End If  'close the If statement
            'otherwise if no jump to here and print direct ie no preview
            ActiveWindow.SelectedSheets.PrintOut
            
    NextNum:
        Next NumDays  'increment the loop counter and go back to start of loop where the counter gets incremented by i
                        'unless it has reached its upper limit
    End With        ' the With..statement
    End Sub     'exit the code
    Last edited by JBeaucaire; 06-23-2013 at 01:21 AM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1