Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default 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
==================
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default 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
==================

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default 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 :)
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Convert a julian gregorian date code into a regular date Robert Excel Worksheet Functions 3 June 13th 06 07:03 PM
copy date based on date -refer to date range mindpeace[_4_] Excel Programming 1 June 3rd 06 01:30 PM
VBA Code to extract records between a date range Daveo Excel Programming 3 September 21st 05 08:27 AM
date range vba code PJ[_4_] Excel Programming 6 September 29th 04 04:16 AM


All times are GMT +1. The time now is 10:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"