View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Otto Moehrbach[_2_] Otto Moehrbach[_2_] is offline
external usenet poster
 
Posts: 1,071
Default How to print select months from worksheet

This macro will set the print range for the last 3 months and print it.
I assumed your dates are in Column A starting with A2 down. I also assumed
that you want to print 10 columns including Column A. HTH Otto
Sub Testmonth()
Dim FourthMonth As Long
Dim c As Long
Dim FirstCell As Range
Dim LastCell As Range
Dim RngToPrint As Range
Set LastCell = Range("A" & Rows.Count).End(xlUp)
If Month(LastCell.Value) 3 Then
FourthMonth = Month(LastCell.Value) - 3
Else
FourthMonth = Month(LastCell.Value) + 9
End If
For c = 1 To 1000
If Month(LastCell.Offset(-c)) = FourthMonth Then
Set FirstCell = LastCell.Offset(-c + 1)
Exit For
End If
Next c
Set RngToPrint = Range(FirstCell, LastCell).Resize(, 10)
RngToPrint.PrintOut
End Sub
"pinkluxe" wrote in message
...
I have a worksheet which is typically sorted by date that is added to quite
often. I need to know if there is a way to pull and print only the most
recent 3 months worth of data from this sheet. I need to send a report to
someone occasionally from this worksheet and instead of having to a) send
them the whole thing, b) print preview after sorting to figure out where 3
months ends and print that or c) sort and select print area for what I
need
to print, I would like to be able to pull that information off a little
easier.

Is this possible? Is there some formula or something that I can use to do
this?

Thanks for your help!