Copy rows from sheet1 to sheet2 based on date.

Roodoc

New Member
Joined
Dec 28, 2018
Messages
13
I have a worksheet similar to below, but with many more rows. What I would like to do is to take the information only from the columns ID, Name, and Due Date to the second worksheet when the due date is between 6 months (+190 days) and 2 months (+70 days) from today's date.

#IDNameFlags CodeClassificationItem DateDue Date
1015563J. SmithAYOffice 1311/15/20182/7/2019
1021257B. WallaceVYCube 78/1/20189/15/2019
201259M. SalinasNFNCube 81/4/20161/7/2019
2023002K. SheaAVYCube 111/6/20196/28/2021

<colgroup><col style="mso-width-source:userset;mso-width-alt:2084;width:43pt" width="57"> <col style="mso-width-source:userset;mso-width-alt:2925;width:60pt" width="80"> <col style="mso-width-source:userset;mso-width-alt:6912;width:142pt" width="189"> <col style="mso-width-source:userset;mso-width-alt:2084;width:43pt" width="57"> <col style="mso-width-source:userset;mso-width-alt:1901;width:39pt" width="52"> <col style="mso-width-source:userset;mso-width-alt:6912;width:142pt" width="189"> <col style="mso-width-source:userset;mso-width-alt:3181;width:65pt" width="87"> <col style="mso-width-source:userset;mso-width-alt:2486;width:51pt" width="68"> </colgroup><tbody>
</tbody>

<thead>
</thead><tbody>
</tbody>
In the second worksheet (sample below) I would have to add further information in each row. I would like these rows to stay intact when updated, if possible. This is because I have other information to add to the reports that are due within 190 days. As I get the steps completed I could add the dates in.

IDNameDue DateProgressReferralTemplateScoreRRGComments
5563J. Smith5/17/2019

259M. Salinas6/3/2019

<colgroup><col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:2596;width:53pt" width="71"> <col style="mso-width-source:userset;mso-width-alt:2889;width:59pt" width="79"> <col style="mso-width-source:userset;mso-width-alt:2742;width:56pt" width="75"> <col style="mso-width-source:userset;mso-width-alt:2633;width:54pt" width="72"> <col style="mso-width-source:userset;mso-width-alt:2962;width:61pt" width="81"> <col style="width:48pt" width="64" span="2"> <col style="mso-width-source:userset;mso-width-alt:3254;width:67pt" width="89"> </colgroup><tbody>
</tbody>


Also, the same information needs to be gathered into a third sheet if it is within 2 months (+70 days) but no longer on the second sheet. With further information gathered there as well.

IDNameDue DatePlacementAssessment
5563J. Smith4/13/2019
259M. Salinas5/15/2019

<colgroup><col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:2596;width:53pt" width="71"> <col style="mso-width-source:userset;mso-width-alt:2889;width:59pt" width="79"> <col style="mso-width-source:userset;mso-width-alt:2742;width:56pt" width="75"> <col style="mso-width-source:userset;mso-width-alt:3072;width:63pt" width="84"> </colgroup><tbody>
</tbody>


I have looked into VBAs and such and can not figure them out for the life of me. I can't figure out how to have this data entered without screwing with the rows I already have entered in sheet 2 and 3. This is a worksheet that I use daily. So I would like for the data to be updated each time I view the worksheet. I have tried advanced filters to no avail. Many thanks to those who attempt to help and know much more than I do.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Please help. I have tried macros, filters, advanced filters, and linking cells. I have also tried to watch many hours of VBA videos and have not found how to complete this function.

It would also be helpful if somebody could point me in the direction that could help me understand how to write the VBA for this.
 
Upvote 0
Not sure about the rest of your requirements but the macro below for me with the data as below

Excel Workbook
ABCDEFGH
1#IDNameFlagsCodeClassificationItem DateDue Date
21015563J. SmithAYOffice 1311/15/201807/04/2019
31021257B. WallaceVYCube 708/01/201815/09/2019
4201259M. SalinasNFNCube 801/04/201607/01/2019
5213316Z. MeBOffice 1106/06/201803/06/2019
62023002K. SheaAVYCube 1101/06/201928/06/2021
Sheet1


Changes

Excel Workbook
ABC
1IDNameDue Date
2
3
4
5
6
Sheet2


to

Excel Workbook
ABC
1IDNameDue Date
25563J. Smith07/04/2019
3316Z. Me03/06/2019
Sheet2


on Sheet2.

Please note that my dates are in dd/mm/yyyy format not mm/dd/yyyy format

Code:
Sub Filterit()
    With Sheets("Sheet1").Range("A1:H" & Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row)
        .AutoFilter Field:=8, Criteria1:= _
        ">=" & CLng(Date + 70), Operator:=xlAnd, Criteria2:="<=" & CLng(Date + 190)
        
        On Error Resume Next
        Intersect(Sheets("Sheet1").Range("B:C,H:H"), .Offset(1).Resize(.Rows.Count - 1)).SpecialCells(xlCellTypeVisible).Copy _
                Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
        On Error GoTo 0
        .AutoFilter
    
    End With
End Sub

Hopefully it will get you started :biggrin:
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,947
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top