Copy all rows with a date equal to today or yesterday to another sheet named 'Final'

jhgiants95

New Member
Joined
Jul 21, 2014
Messages
33
Office Version
  1. 365
Platform
  1. Windows
I am looking to copy and paste as values (due to formulas) all rows whose column A has a date equal to today or yesterday. This report is run at the end of each day and needs to have certain information from the past two days. Both sheets have the same columns and format. The paste should begin in row 2 column A of the sheet "Final".

The sheet that will copy the data over is called "Input". Thanks for any help or guidance as I could not figure out based on searching how to do this.

The columns in the final sheet have been formatted properly so everything should be correct in the result sheet.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Can you please explain. I don't believe that I can select two dates for this. There is quite a bit of data here so I cannot simply browse through a sorted list and copy it on my own. Thanks.
 
Upvote 0

Excel 2010
ABCDEFGHIJK
1NameDateNumberNameDateNumber
2ABC1/23/2018921/26/2018
3ABC1/25/2018511/25/2018
4ABC1/26/20184
5ABC1/27/20185
6ABC1/29/201820
7ABC1/30/201836
8ABC2/1/201891
9ABC2/2/201862
10ABC2/5/201814
11ABC2/5/201845
12ABC1/26/201881
13ABC2/8/201815
14TDS1/10/201829
15TDS1/27/201851
16TDS2/14/201897
17TDS1/25/201897
18TDS3/14/201840
Input
Cell Formulas
RangeFormula
J2=TODAY()
J3=TODAY()-1



Excel 2010
ABC
1NameDateNumber
2ABC1/25/201851
3ABC1/26/20184
4ABC1/26/201881
5TDS1/25/201897
Final


Remember to open the advanced filter from the destination sheet
 
Upvote 0
Try this:
Code:
Sub Copy_Today_Yesterday()
'Modified 1-26-18 7:25 PM EST
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
ansT = DateAdd("d", 0, Date)
ansY = DateAdd("d", -1, Date)
Sheets("Final").Activate
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    With Range("A1:A" & Lastrow)
       .AutoFilter Field:=1, Criteria1:=ansT, Operator:=xlOr, Criteria2:=ansY
        .Offset(1).EntireRow.Copy
        Sheets("Input").Range("A2").PasteSpecial xlPasteValues
        .AutoFilter
    End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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