I have the following code which works perfectly until I want not just today's date, but the past 5 days as well
Code
Sub RecentUpdates()
Dim x As Integer
Dim NextRow As Range
Dim WhatToCopy As String
Dim wsheet As Worksheet
For Each wsheet In Worksheets
If wsheet.name <> "Updates" Then
x = 2
Set NextRow = Sheets("Updates").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
Do Until x > 500 Or wsheet.Range("A" & x) = ""
If wsheet.Range("A" & x) = Date Then
wsheet.Rows(x).EntireRow.Copy NextRow
End If
If wsheet.Range("D" & x) = Date Then
wsheet.Rows(x).EntireRow.Copy NextRow
End If
Set NextRow = Sheets("Updates").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
x = x + 1
Loop
End If
Next wsheet
End Sub
Display More
I've tried
Code
If wsheet.Range("A" & x) = Date or Date - 1 or Date - 2 or Date - 3 or Date - 4 or Day - 5 Then
however, this copies every date, even if they are way older than the previous 5 days days. How do I modify so that it will copy and paste all dates that are within the past 5 days from today?