If date more than

  • Thread starter Thread starter Kash
  • Start date Start date
K

Kash

Hello there.. I was trying to cut the entire row and paste it to another
sheet if date is more than 20 days

say date column is 'H'

Someone please help me on this..

Thank you..
 
If date is more than 20 days what. In the past? In the future? something else?
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
Hi,

try this

Sub stance()
Dim MyRange
Dim CopyRange As Range
Set sht = Sheets("Sheet1")
lastrow = sht.Cells(Cells.Rows.Count, "H").End(xlUp).Row
Set MyRange = sht.Range("H1:H" & lastrow)
For Each c In MyRange
If c.Value < Date - 20 Then
If CopyRange Is Nothing Then
Set CopyRange = c.EntireRow
Else
Set CopyRange = Union(CopyRange, c.EntireRow)
End If
End If
Next
If Not CopyRange Is Nothing Then
CopyRange.Copy Destination:=Sheets("Sheet2").Range("A1")
End If
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
Glad I could help and thanks for the feedback
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top