RANGE DATE CODE
tkraju via OfficeKB.com wrote:
I have date range in Col A:A.I need code that selects A2 to 3 months back
date from today.
Suppose 3 months back date is 9 th Dec 2006 and it exists in A15 cell ,the
range to select
is A2:A15.What code will give this result.Thanks for any help in this regard.
Assuming the dates are in descending order and there are no blanks in your
list of dates, this will select the range from A1 to the last cell with a
date greater than Now() - 30 (days):
=================
Sub dates()
Dim MyDatesList As Range
Set MyDatesList = Worksheets("Sheet1").Range("A1", _
Worksheets("Sheet1").Range("A2").End(xlDown))
For Each dt In MyDatesList
If dt.Value Now() - 30 Then
Worksheets("Sheet1").Range("A1", dt).Select
Else
End If
Next dt
End Sub
==================
|