ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to print select months from worksheet (https://www.excelbanter.com/excel-discussion-misc-queries/204371-how-print-select-months-worksheet.html)

pinkluxe

How to print select months from worksheet
 
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!

JLatham

How to print select months from worksheet
 
One question becomes do you mean within the past 3 months or within the past
90 days.
But this formula would work for the 3 month deal, example:
for date in September, then July, August and September are the 3 months.

Use a helper column to achieve this. Assume that you have dates in column A
and that your data starts on row 2. Then put this formula in the helper
column on row 2:

=(YEAR(NOW())-YEAR(A2))*12+MONTH(NOW())-MONTH(A2)<3

This will return TRUE for months in the past 3 months (where current month
is one of those 3 months), and FALSE for all others.

Then you can filter the data based on that column for TRUE and only the
entries for the 3 months will be displayed and you can print the sheet and
only those entries will print out.

If you meant within the past 90 days, then use this formula instead:
=(NOW()-A2)<91
Again, results will be TRUE or FALSE.


"pinkluxe" wrote:

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!


Otto Moehrbach[_2_]

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!





All times are GMT +1. The time now is 08:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com