ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Date Ranges (https://www.excelbanter.com/excel-programming/297815-using-date-ranges.html)

tchillie

Using Date Ranges
 
I have a table of information in Excel. One of the columns is a date.
I would like to automatcally return a value if the date falls within
certain ranges. For example, if the date is between 1/1/01 and
5/31/01 then return "A." But if the date is between 6/1/01 and
5/31/02 then return "B." The problem I have is that the date ranges
cross years and are not always 365 days. I have done this using
formulas, but with 8 ranges, I have a nested IF statement with 7 If's.
Any suggestions using VBA?

If anyone wants more info, just let me know.

Don Guillett[_4_]

Using Date Ranges
 
Why not create a table and use vlookup(yourdate,table,2)
A B
5/31/01 A

--
Don Guillett
SalesAid Software

"tchillie" wrote in message
om...
I have a table of information in Excel. One of the columns is a date.
I would like to automatcally return a value if the date falls within
certain ranges. For example, if the date is between 1/1/01 and
5/31/01 then return "A." But if the date is between 6/1/01 and
5/31/02 then return "B." The problem I have is that the date ranges
cross years and are not always 365 days. I have done this using
formulas, but with 8 ranges, I have a nested IF statement with 7 If's.
Any suggestions using VBA?

If anyone wants more info, just let me know.




Arvi Laanemets

Using Date Ranges
 
Hi

Something like
=CHOOSE(MATCH(A1,{38352,38168,37986,37802,37621,37 437,37256,37072,36891},-1)
,"A","B","C","D","E","F","G","H")

where A1 contains date, and 5-digit numbers in MATCH array represent dates
in descending order (in my example they are 31.12.2004, 30.06.2004,
31.12.2003, ..., 31.12.2000). Of course the number of matches isn't
infinite, but 29 is considerable better as 7.


--
Arvi Laanemets
(Don't use my reply address - it's spam-trap)


"tchillie" wrote in message
om...
I have a table of information in Excel. One of the columns is a date.
I would like to automatcally return a value if the date falls within
certain ranges. For example, if the date is between 1/1/01 and
5/31/01 then return "A." But if the date is between 6/1/01 and
5/31/02 then return "B." The problem I have is that the date ranges
cross years and are not always 365 days. I have done this using
formulas, but with 8 ranges, I have a nested IF statement with 7 If's.
Any suggestions using VBA?

If anyone wants more info, just let me know.





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

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