ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If date more than (https://www.excelbanter.com/excel-programming/441414-if-date-more-than.html)

Kash

If date more than
 
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..

Mike H

If date more than
 
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.


"Kash" wrote:

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..


Kash

If date more than
 
I'm sorry.. if date is 20 days behind..

Mike H

If date more than
 
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.


"Kash" wrote:

I'm sorry.. if date is 20 days behind..


Kash

If date more than
 
This works great.. Thank you Mike

Mike H

If date more than
 
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.


"Kash" wrote:

This works great.. Thank you Mike



All times are GMT +1. The time now is 05:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com