+ Reply to Thread
Results 1 to 5 of 5

Thread: Printing Macro-piece of code

  1. #1
    Registered User
    Join Date
    10-06-2006
    Posts
    15

    Printing Macro-piece of code

    OK, I have a piece of code that colors cells based on their expiration date:

    Public Sub Expiring_Dates ()
    
    x = Cells(Rows.Count, 1).End(xlUp).Row
    For a = 1 To x
    For b = 1 To 3
    If Cells(a, b) >= Now() + 7 And Cells(a, b) <= Now() + 14 Then
    Cells(a, b).Interior.ColorIndex = 6
    ElseIf Cells(a, b) <= Now() + 7 Then
    Cells(a, b).Interior.ColorIndex = 3
    End If
    Next b
    Next a
    
    End Sub
    What I want to do is add a macro that prints the ROWS with those specifically colored columns.

    I have:

    Sub Printer_Function ()
    ActiveSheet.PageSetup.PrintArea = 
    
    End Sub
    I just don't know what to place after the equal sign to get it to do what I want. Can anybody help me?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979
    Hello Eddie barzoon,

    Are both colors to printed or only one? How much of the row is to be included in the printing, ie. what is the last column in the row?

    Sincerely,
    Leith Ross

  3. #3
    Forum Guru mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    2,998
    I would write a routine that hid the rows with the wrong colors, then printed, then unhid the rows.

  4. #4
    Registered User
    Join Date
    10-06-2006
    Posts
    15
    Quote Originally Posted by Leith Ross
    Hello Eddie barzoon,

    Are both colors to printed or only one? How much of the row is to be included in the printing, ie. what is the last column in the row?

    Sincerely,
    Leith Ross

    Yes, any row that contains that color, they are red and yellow, would need to print. The last column in the row is the tenth column or column J.

  5. #5
    Registered User
    Join Date
    10-06-2006
    Posts
    15
    Quote Originally Posted by mikerickson
    I would write a routine that hid the rows with the wrong colors, then printed, then unhid the rows.

    Mind helping me with that?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0