![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Houston, TX
Posts: 303
|
This formula in A1 properly displays 2004
=YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0)) This formula in A2 properly displays 01-01-04 =DATE(A1,1,1) When I replace A1 in the formula above with the actual formula from A1, I get an error with DATE just after ((( highlighted. Why won't this work? =DATE((YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0))),1,1) |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Quote:
If your formula for the year in A1 works OK, then a cursory look at your formula in A2, shows you have an extra left parentheses ... so replace the formual in A2 with =DATE(YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0))),1,1) I have not cheked this formula ... but give it a shot. Please post back if it works for you ... otherwise explain a little further and let us take it from there! _________________ Yogi Anand Edit: Deleted inactive website from hardcoded signature [ This Message was edited by: Yogi Anand on 2003-01-19 14:19 ] |
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Houston, TX
Posts: 303
|
The formula in A2 works and I count the net parentheses as zero. In your suggestion, I count one extra right paren. It's gotta be something else. Thanks for all help.
|
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
Aladin |
|
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Quote:
Some times it is so difficult to check -- especially one's own work. If you like you can email your workbook to me and I will be glad to look at where the problem might be.
__________________
Regards! Yogi Anand, D.Eng, P.E. Energy Efficient Building Network LLC www.energyefficientbuild.com |
|
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Hi Jim:
I did get you workbook -- I did analyze it. The problem was that in using the year calculation in the date formula you exceeded the limit of 7 levels of nested functions. It is surprising that Excel will not point this out but consider this an error. Solution -- use the results of your year calculation in another formula so you don't exceed the limit of nested functions. Please post back if it works for you ... otherwise explain alittle further and let us take it from there!
__________________
Regards! Yogi Anand, D.Eng, P.E. Energy Efficient Building Network LLC www.energyefficientbuild.com |
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
This formula in A1 properly displays 2004 =YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0)) This formula in A2 properly displays 01-01-04 =DATE(A1,1,1) When I replace A1 in the formula above with the actual formula from A1, I get an error with DATE just after ((( highlighted. Why won't this work? =DATE((YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0))),1,1) Pilot, I see you already got a reply as to the nature of the problem: Wrapping the first working formula within an additional function causes to exceed a built-in limit in Excel. One solution is what Yogi suggested, another for which I opted is: =DATE(YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC((BaseDate-$AI$2)/365),YEARS)),SICK)+1),SICK,0)),1,1) where BaseDate is a named formula consisting of: [A] =DATE(Base,12,31) If this solution sounds good to you, activate Insert|Name|Define, enter BaseDate (or something more intelligible) as name in the Names in Workbook box, and enter [A] as formula in the Refers to box. Aladin [ This Message was edited by: Aladin Akyurek on 2002-03-29 11:20 ] |
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Feb 2002
Location: Houston, TX
Posts: 303
|
Thanks Yogi and Aladin, it works like a charm. I like the limitation workaround that Aladin suggested - and I learned something new and quite useful, too. This is a great resource!!!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|