Does anyone have any suggestions on how to determine the value within lists?
For example,
[1]
There is a given date in cell A1, 06-Jun without concerning year, I would
like to determine the value within column C, it should return 6 in cell A2,
because 06-Jun is equal to or larger than 05-Jun and less than 21-Jun.
[2]
There is a given date in cell A1, 05-Jun without concerning year, I would
like to determine the value within column C, it should return 6 in cell A2,
because 05-Jun is equal to or larger than 05-Jun and less than 21-Jun.
[3]
There is a given date in cell A1, 07-Mar without concerning year, I would
like to determine the value within column C, it should return 24 in cell A2,
because 07-Mar is equal to or larger than 05-Mar and less than 21-Mar.
Does anyone have any suggestions on how to do it in Excel?
Thanks in advance for any suggestions
Eric
There are list under columns
[B] [C]
21-Mar 1
05-Apr 2
20-Apr 3
05-May 4
21-May 5
05-Jun 6
21-Jun 7
07-Jul 8
23-Jul 9
07-Aug 10
23-Aug 11
07-Sep 12
22-Sep 13
08-Oct 14
23-Oct 15
08-Nov 16
22-Nov 17
07-Dec 18
21-Dec 19
05-Jan 20
20-Jan 21
04-Feb 22
19-Feb 23
05-Mar 24
|
|
0
|
|
|
|
Reply
|
Utf
|
6/6/2010 5:17:38 AM |
|
Eric,
Please attach your workbook.
Click on the *Reply* button, then scroll down and see *Manage
Attachments*.
--
stanleydgromjr
------------------------------------------------------------------------
stanleydgromjr's Profile: http://www.thecodecage.com/forumz/member.php?u=503
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=207432
http://www.thecodecage.com/forumz
|
|
0
|
|
|
|
Reply
|
stanleydgromjr
|
6/6/2010 12:33:36 PM
|
|
This gets complicated because yo uprobably have a date with the year
hidden since you are only displaying month and day. The function has to
ignore the year which may or may not be entered correctly. I think you
need a UDF macro. I wrote one that I tried to make idiot proff no
matter what a person entered as the year on the worksheet. Put this
function in A2
=ReturnDateIndex(A1,$B$1:$C$24)
The macro is below
Function ReturnDateIndex(LookupDateStr As String, Target As Range)
'convert date to a serial date if it is not already
LookupDate = DateValue(LookupDateStr)
StartRow = Target.Row
NumberRows = Target.Rows.Count
LastRow = StartRow + NumberRows - 1
ReturnDateIndex = "VALUE"
FoundNewYear = False
'assume dates are in order
'if a day is earlier in the year than previous
'date then a new year must of been found
StartYear = Year(LookupDate)
StartMonth = Month(LookupDate)
StartDay = Day(LookupDate)
PreviousDate = DateValue(Cells(StartRow, Target.Column))
'convert date to same year as lookup date
PreviousDate = DateSerial(StartYear, _
Month(PreviousDate), _
Day(PreviousDate))
For RowCount = StartRow To LastRow
CellDate = DateValue(Cells(RowCount, Target.Column))
'convert date to same year as lookup date
CellDate = DateSerial(StartYear, _
Month(CellDate), _
Day(CellDate))
'if true then we reached a new year
If CellDate < PreviousDate And _
FoundNewYear = False Then
FoundNewYear = True
'move date to next year
LookupDate = DateSerial(StartYear + 1, _
Month(LookupDate), _
Day(LookupDate))
End If
If FoundNewYear = True Then
'move date to next year
CellDate = DateSerial(StartYear + 1, _
Month(CellDate), _
Day(CellDate))
End If
If RowCount = LastRow Then
If LookupDate >= CellDate Then
ReturnDateIndex = Cells(RowCount, Target.Column + 1)
End If
Else
NextDate = DateValue(Cells(RowCount + 1, Target.Column))
'convert date to same year as lookup date
If FoundNewYear = True Then
'move date to next year
NextDate = DateSerial(StartYear + 1, _
Month(NextDate), _
Day(NextDate))
Else
NextDate = DateSerial(StartYear, _
Month(NextDate), _
Day(NextDate))
End If
If LookupDate >= CellDate And _
LookupDate <= NextDate Then
ReturnDateIndex = Cells(RowCount, Target.Column + 1)
Exit For
End If
End If
Next RowCount
End Function
--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=207432
http://www.thecodecage.com/forumz
|
|
0
|
|
|
|
Reply
|
joel
|
6/6/2010 12:54:21 PM
|
|
|
2 Replies
553 Views
(page loaded in 0.223 seconds)
Similiar Articles: How to determine the numeric value of a date field? - microsoft ...I'm using Access 2000 and have a db with some queries set up by someone else. The query is supposed to list those who are of a certain age: For thos... P value in excel - microsoft.public.excel.programmingHi, Is there a method/code to find out the p value in excel. I have 30 or more data points and i wish to find out is the data normal or not based... How to calculate the present value of a security, $5000 @ 7%, 20y ...I'm trying to use excell to calculate the present value of a security that will pay $5000.00 in 20 years at 7% interest. PV=FVn/(1+I)N ... how do I calculate the change in a value between 2 Access records ...I have a form containing a table's history of prices by date. I want to calculate the change in price from one record to the next. How do I calcul... Find Recordset field number using field value - microsoft.public ...I am very new to access and have a question regarding a recordset. I would like to access a field in a recordset based on an index but I am not sure ... Query input value to determine another field results - microsoft ...In the below query I want the max year field to pich the associated school that the coach was affiliated with that max year. Currently the query giv... How do I find the second highest value. - microsoft.public.excel ...I have a set of numbers where I need to find the highest value and the next highest value. I can use MAX to find the highest, but how do I find the ... how to calculate billable rate using base rate and percentage ...I have a billable rate of $70 with a mark up percentage of 17.65%. How do I calculate the base rate? ... How to check if the values in a range of cells are greater than 0 ...Basically I want to check like IF(B3:B5 > 0,B1), if any of the values in B3 to B5 cells are greater than 0 then I take the value from the cell B1. ... how to pass a value from vb6 to a parameter in crystal - microsoft ...Hi, Does anyone know how to pass a value from vb6 to a parameter in crystal? Thanks & regards, edmond ... How to Determine Value of Products and ServicesWhen it is time for you to determine the value of a product or service, you need to ask some questions about what you are selling. I reviewed some of the ... How to Determine a Selling Price for a Business | eHow.comMany business owners have trouble determining how to price their business for sale. That is partly due to the fact that there is no magic formula that can be plugged ... Determine Value - How To Information | eHow.comDon't just sit there scratching your head, find useful info on Determine Value on eHow. Get essential tips and learn more about everything from Tutorial on OP Amp ... How to Determine the Value of Antiques and Collectibles | Suite101.comThere are many factors that determine the value of antiques and collectibles. One is changing trends, which can play a huge role in the item's appraisal. How to Determine Absolute Value - For DummiesIn algebra, the absolute value operation tells you how far a number is from zero. It doesn’t pay any attention to whether the number is less than or greater than 7/31/2012 3:03:50 PM
|