views:

46

answers:

1

I run a report every week and would like to cut the rows for a particular date range into a new worksheet (i.e. all rows with transactions between the 16th of one month to the 15th of the following month).

I'd like to cut all rows between 07/16 and 08/15 and past them in a new worksheet called "Aug" And cut all rows between 08/16 and 09/15 and past them in a new workseet called "Sept"

Example data

Column A - Column B - Column C

Post Date - Name - Vendor

07/25/10 - Wilson - Starbucks

08/05/10 - Wilson - American Airlines

08/14/10 - Guang - Apple Store

08/15/10 - McGee - Staples

08/17/10 - Curry - AT&T

09/02/10 - Johnson - Exxon

09/11/10 - Simms - Old Navy

+1  A: 

Ok, this will work if you have a header row on the destination sheet. I just implemented the August copy and paste, but it would be simple to add September or make it completely generic and have it do the whole year.

Dim workingrow As Range

For Each workingrow In Sheets("Main").Rows

If (workingrow.Cells(1, 1).Value >= DateValue("7/16/2010")) And _ 
   (workingrow.Cells(1, 1).Value <= DateValue("8/15/2010")) Then
        workingrow.Copy (Sheets("Aug").Rows(1).End(xlDown).Offset(1, 0))
End If

Next workingrow
Lance Roberts
Thanks for help. I'm a beginner with VBA - i only use it for moving objects/editing graphs.I think having a tab for each month would work. With your above post I'm having trouble with the last commandworkingrow.Copy (Sheets("Aug").Rows(1).End(xlDown).Offset(1, 0))I'm getting Application-defined error
Sam
I'd like to cut them
Sam
@Sam, My guess would be that you're getting the error because the sheet is empty, which is why I said you needed to have a header row. It needs at least one pre-existing row to work right (because of how the End method works). To make it a __Cut__, just substitute Cut for Copy.
Lance Roberts