Refine formula

tallgeese980

Board Regular
Joined
Nov 19, 2009
Messages
80
Hi all i have created a formula that i believe can be refined and shorted because it has become a huge mess. The formula below is used to pull data based on a specific date.

=IF(BS$7>=$D$9,IF(AND(($D$9<="12/31/2012"+0),($D$9>"12/31/2011"+0)),'Input Data'!$H$85*HLOOKUP('Input Data'!$C$3,'Allocation %s'!$C$3:$L$23,5,0),IF(AND(($D$9<="12/31/2013"+0),($D$9>"12/31/2012"+0)),'Input Data'!$H$91*HLOOKUP('Input Data'!$C$3,'Allocation %s'!$C$3:$L$23,5,0),IF(AND(($D$9<="12/31/2014"+0),($D$9>"12/31/2013"+0)),'Input Data'!$H$97*HLOOKUP('Input Data'!$C$3,'Allocation %s'!$C$3:$L$23,5,0),IF(AND(($D$9<="12/31/2015"+0),($D$9>"12/31/2014"+0)),'Input Data'!$H$103*HLOOKUP('Input Data'!$C$3,'Allocation %s'!$C$3:$L$23,5,0),IF(AND(($D$9<="12/31/2016"+0),($D$9>"12/31/2015"+0)),'Input Data'!$H$109*HLOOKUP('Input Data'!$C$3,'Allocation %s'!$C$3:$L$23,5,0),IF(AND(($D$9<="12/31/2017"+0),($D$9>"12/31/2016"+0)),'Input Data'!$H$109*HLOOKUP('Input Data'!$C$3,'Allocation %s'!$C$3:$L$23,5,0),0)))))),0)
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Yeah I agree and tried but was unable to get it to work correctly. Also, the formual has an issue with the dates when pulling the data. Its pulling numbers for a depreciation schedule on multiple projects with diferent start dates but all having 4 year depreciation lives. However, it ends up pulling depreciation for a full year (the last year of the derprecation life) even though the project started on the 2/11/11. So for 2015 it should only charge up till feb but it pulls data in for every month that year.
 
Upvote 0
Two quick recommendations:

1. Replace all instances of: AND(($D$9<="12/31/yyyy"+0),($D$9>"12/31/yyyy"+0))

With: YEAR($D$9)=yyyy

2. Put the formula =HLOOKUP('Input Data'!$C$3,'Allocation %s'!$C$3:$L$23,5,0)

in some empty cell. Then replace all instances of that formula with the reference to that cell. Assuming that cell is G1:

=IF(BS$7>=$D$9,IF(YEAR($D$9)=2012,'Input Data'!$H$85*$G$1,IF(YEAR($D$9)=2013,'Input Data'!$H$91*$G$1,IF(YEAR($D$9)=2014,'Input Data'!$H$97*$G$1,IF(YEAR($D$9)=2015,'Input Data'!$H$103*$G$1,IF(YEAR($D$9)=2016,'Input Data'!$H$109*$G$1,IF(YEAR($D$9)=2017,'Input Data'!$H$109*$G$1,0)))))),0)

Hopefully that works. I'm sure you could even shorten it more since there appears to be a pattern (Hxxx changes by six rows for each year....) I also noticed that H109 is used as the multiplier for both 2016 and 2017. Either a typo, or it's meant to be that way based on your data.
 
Upvote 0
Possible shorter solution:

=IF(BS$7>=$D$9,INDIRECT("$H$"&LOOKUP(YEAR($D$9),{2012,2013,2014,2015,2016,2017},{85,91,97,103,109,115}))*$G$1)
 
Upvote 0
I would think that perhaps selecting singling out the month would work but unfortunately then it excludes the year too.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top