ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   RANGE DATE CODE (https://www.excelbanter.com/excel-programming/384895-range-date-code.html)

tkraju via OfficeKB.com

RANGE DATE CODE
 
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.

--
Message posted via http://www.officekb.com


Damien McBain[_3_]

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

tkraju via OfficeKB.com

RANGE DATE CODE
 
Thanks,McBain,but my dates in range A:A are in ascending order and no blanks,
holidays excluded.
will this code takes care of this.

Damien McBain 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
==================


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200703/1


Damien McBain[_3_]

RANGE DATE CODE
 
tkraju via OfficeKB.com wrote:

Thanks,McBain,but my dates in range A:A are in ascending order and no blanks,
holidays excluded.
will this code takes care of this.


It will select from A1 down to the farthest date down the list that
satisfies the driteria ie now() - 30 or whatever you choose.

Damien McBain 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
==================


tkraju via OfficeKB.com

RANGE DATE CODE
 
Many thanks,I substituted '' with '<' ,my ascending order range given
correct results.
Thank you once again.

Damien McBain wrote:
Thanks,McBain,but my dates in range A:A are in ascending order and no blanks,
holidays excluded.
will this code takes care of this.


It will select from A1 down to the farthest date down the list that
satisfies the driteria ie now() - 30 or whatever you choose.

I have date range in Col A:A.I need code that selects A2 to 3 months back
date from today.

[quoted text clipped - 22 lines]
End Sub
==================


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200703/1


Damien McBain[_3_]

RANGE DATE CODE
 
tkraju via OfficeKB.com wrote:

Many thanks,I substituted '' with '<' ,my ascending order range given
correct results.
Thank you once again.


No worries. Remember to read the group for a while after receiving some
help and see if you can offer some as well - this keeps it free for all of
us :)


All times are GMT +1. The time now is 03:57 PM.

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