VLOOKUP problem because data not always in order

nmualum

New Member
Joined
Jul 26, 2017
Messages
9
So we have a pricing spreadsheet that has a range of rows for each fiscal year (FY13 thru FY20). When we price a part, there is a lead time associated with that part; i.e. how long will it take us to receive the part from our supplier to send out to the end customer. Sometimes the lead time may be 10 days, some times it is over a year.

A quote to the customer is good for 90 days from the date it is created. And there is a price expiration date (when will we no longer be able to guarantee the quoted price). We use this information to calculate what we call a Quote Half Life date. We take todays date, the lead time and 1/2 of the quote life (90 days, so 45 days is used). Add all that together to get a date. If the quote validity expires prior to that date, we can still quote the part, but we increase the price by an escalation percentage to cover the risk that we won't be able to get the part for exactly the same price.
Our pricing spreadsheet uses a block of cells like this:
[TABLE="width: 518"]
<tbody>[TR]
[TD="class: xl39250, width: 41, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] "][/TD]
[TD="class: xl39250, width: 42, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] "][/TD]
[TD="class: xl39250, width: 55, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] "][/TD]
[TD="class: xl39250, width: 41, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] "][/TD]
[TD="class: xl39250, width: 55, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] "][/TD]
[TD="class: xl39250, width: 41, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] "][/TD]
[TD="class: xl39258, width: 83, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY16
[/TD]
[TD="class: xl39258, width: 82, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY17
[/TD]
[TD="class: xl39258, width: 82, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY18
[/TD]
[TD="class: xl39258, width: 82, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY19
[/TD]
[TD="class: xl39258, width: 82, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY20
[/TD]
[/TR]
[TR]
[TD="class: xl39279, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]Escalation Type
[/TD]
[TD="class: xl39263, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 4"]Date Range
[/TD]
[TD="class: xl39263, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]Escalation %
[/TD]
[TD="class: xl39263, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]Escalation %
[/TD]
[TD="class: xl39263, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]Escalation %
[/TD]
[TD="class: xl39263, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]Escalation %
[/TD]
[TD="class: xl39259, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]Escalation %
[/TD]
[/TR]
[TR]
[TD="class: xl39280, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY13
[/TD]
[TD="class: xl39272, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2012
[/TD]
[TD="class: xl39272, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/1013
[/TD]
[TD="class: xl39261, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1350
[/TD]
[TD="class: xl39261, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1690
[/TD]
[TD="class: xl39261, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.2010
[/TD]
[TD="class: xl39261, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.2330
[/TD]
[TD="class: xl39261, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.2650
[/TD]
[/TR]
[TR]
[TD="class: xl39277, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY14
[/TD]
[TD="class: xl39274, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2013
[/TD]
[TD="class: xl39274, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2014
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1030
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1360
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1670
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1980
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.2290
[/TD]
[/TR]
[TR]
[TD="class: xl39277, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY15
[/TD]
[TD="class: xl39274, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2014
[/TD]
[TD="class: xl39274, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2015
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0610
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0930
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1220
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1520
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1820
[/TD]
[/TR]
[TR]
[TD="class: xl39277, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY16
[/TD]
[TD="class: xl39274, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2015
[/TD]
[TD="class: xl39274, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2016
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0300
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0610
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0890
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1180
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1480
[/TD]
[/TR]
[TR]
[TD="class: xl39277, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY17
[/TD]
[TD="class: xl39274, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2016
[/TD]
[TD="class: xl39274, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2017
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"][/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0300
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0580
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0860
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.1140
[/TD]
[/TR]
[TR]
[TD="class: xl39277, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY18
[/TD]
[TD="class: xl39274, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2017
[/TD]
[TD="class: xl39274, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2018
[/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"][/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"][/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0269
[/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0538
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0820
[/TD]
[/TR]
[TR]
[TD="class: xl39267, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]Quote Half Life
[/TD]
[TD="class: xl39269, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]11/7/2018
[/TD]
[TD="class: xl39269, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"][/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0400
[/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0300
[/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0300
[/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0300
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"][/TD]
[/TR]
[TR]
[TD="class: xl39282, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]Current
[/TD]
[TD="class: xl39270, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]11/8/2018
[/TD]
[TD="class: xl39270, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"][/TD]
[TD="class: xl39265, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0000
[/TD]
[TD="class: xl39253, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0000
[/TD]
[TD="class: xl39253, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0000
[/TD]
[TD="class: xl39253, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0000
[/TD]
[TD="class: xl39253, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0260
[/TD]
[/TR]
[TR]
[TD="class: xl39268, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY19
[/TD]
[TD="class: xl39269, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2018
[/TD]
[TD="class: xl39269, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2019
[/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"][/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"][/TD]
[TD="class: xl39286, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0000
[/TD]
[TD="class: xl39286, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0262
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0530
[/TD]
[/TR]
[TR]
[TD="class: xl39268, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]FY20
[/TD]
[TD="class: xl39269, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2019
[/TD]
[TD="class: xl39269, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]9/30/2020
[/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"][/TD]
[TD="class: xl39255, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"][/TD]
[TD="class: xl39284, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] "][/TD]
[TD="class: xl39285, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] "][/TD]
[TD="class: xl39286, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0000
[/TD]
[TD="class: xl39251, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , colspan: 2"]1.0260
[/TD]
[/TR]
</tbody>[/TABLE]

The row with the Quote Half Life date is populated with the calculated date. The row for 'Current' is the Quote Half Life date + 1 day.
If the lead time is short, say 10 days, the quote half life ends up as a date in May, and the vlookup to figure out what row to use works fine. But in this case, I put in a lead time of 200 days, and now the column with the dates is not sequential. So the vlookups return the wrong escalation value.

My first thought was that the Quote Half Life and Current Rows should logically be at the end of the table. But when I tried that with a long lead time, it worked fine. But if I tested it with a short lead time, it would fail because the dates wouldn't be in sequence.

My two thoughts on possible solutions are using vba to code this, loop thru the dates to find the proper match for the expiration date; if I find multiple date ranges that would work, somehow programmatically determine which one was actually the right date. My second idea was to make this block of rows/columns an actual table, so I could populate it with the calculated date, then resort it by that column, then apply the vlookup against it. Complicating that solution is the fact that this block of cells has a ****-ton of merged cells; the results of this spreadsheet are printed and sent to the customer, so whoever created this beast (8 years ago, long gone) has it formatted to fit on a page. When I tried to insert a table to contain this data, it 'unmerged' all the cells, causing havoc.

Does anyone have any thoughts on this? I've been banging my head against the wall for a day...

Thanks
Steve
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Steve,

Welcome to the board and thank you for such a great first explanation of what you are trying to accomplish, so many times people have a hard time getting their point across, and I am sometimes one of them...so I can complain, but again lots of good information.

That being said could you add your current formula(s) and the cell location(s) you are working with
 
Upvote 0
Drrellik,
Thanks for spending the time looking at this. I'll try to break down the convoluted logic as best I can. Having issues pasting screen shots, so doing this the hard way.

This section is where the end user does the pricing. They enter in the quantity, Unit of Measure (Each), the base cost, the lead time for this quantity, and the expiration date for the last quote of these parts we received from the supplier.
[table="width: 500, class: grid, align: center"]
[tr]
[td][/td]
[td]A[/td]
[td]B[/td]
[td]C[/td]
[td]D[/td]
[td]E/F[/td]
[td]G[/td]
[/tr]
[tr]
[td]41[/td]
[td]QTY[/td]
[td]UOM[/td]
[td]UnitCost[/td]
[td]LeadTime[/td]
[td]ExpiryDate[/td]
[td]EscalCost[/td]
[/tr]
[tr]
[td]42[/td]
[td]PRICE LIST[/td]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[tr]
[td]43[/td]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[tr]
[td]44[/td]
[td]1[/td]
[td]EA[/td]
[td]150.0000[/td]
[td]200[/td]
[td]7/10/2018[/td]
[td]158.07[/td]
[/tr]
[/table]



Here's the main section, with row and column headers:
[table="width: 1000, class: Grid, align: Center"]
[tr]
[td]Row[/td]
[td]M/N[/td]
[td]O/P[/td]
[td]Q/R[/td]
[td]S/T[/td]
[td]U/V[/td]
[td]W/X[/td]
[td]Y/Z[/td]
[td]AA/AB[/td]
[/tr]
[tr]
[td]54[/td]
[td][/td]
[td][/td]
[td][/td]
[td]fy16[/td]
[td]fy17[/td]
[td]fy18[/td]
[td]fy19[/td]
[td]fy20[/td]
[/tr]
[tr]
[td]55[/td]
[td]Escalation Type[/td]
[td]Date[/td]
[td]Range[/td]
[td]Esc%[/td]
[td]Esc%[/td]
[td]Esc%[/td]
[td]Esc%[/td]
[td]Esc%[/td]
[/tr]
[tr]
[td]56[/td]
[td]FY13[/td]
[td]9/30/2012[/td]
[td]9/30/2013[/td]
[td]1.1030[/td]
[td]1.1360[/td]
[td]1.1670[/td]
[td]1.1980[/td]
[td]1.2290[/td]
[/tr]
[tr]
[td]57[/td]
[td]FY14[/td]
[td]09/30/2013[/td]
[td]09/30/2014[/td]
[td]1.0610[/td]
[td]1.0930[/td]
[td]1.1220[/td]
[td]1.1520[/td]
[td]1.1820[/td]
[/tr]
[tr]
[td]58[/td]
[td]FY15[/td]
[td]09/30/2014[/td]
[td]09/30/2015[/td]
[td]1.0300[/td]
[td]1.0610[/td]
[td]1.0890[/td]
[td]1.1180[/td]
[td]1.1480[/td]
[/tr]
[tr]
[td]59[/td]
[td]FY16[/td]
[td]09/30/2015[/td]
[td]09/30/2016[/td]
[td]1.0300[/td]
[td]1.0610[/td]
[td]1.0890[/td]
[td]1.1180[/td]
[td]1.1480[/td]
[/tr]
[tr]
[td]60[/td]
[td]FY17[/td]
[td]09/30/2016[/td]
[td]09/30/2017[/td]
[td][/td]
[td]1.0300[/td]
[td]1.0580[/td]
[td]1.0860[/td]
[td]1.1140[/td]
[/tr]
[tr]
[td]61[/td]
[td]FY18[/td]
[td]09/30/2017[/td]
[td]09/30/2018[/td]
[td][/td]
[td][/td]
[td]1.0269[/td]
[td]1.0300[/td]
[td][/td]
[/tr]
[tr]
[td]62[/td]
[td]QuoteHalfLife[/td]
[td]11/7/2018[/td]
[td][/td]
[td]1.0400[/td]
[td]1.0300[/td]
[td]1.0300[/td]
[td]1.0300[/td]
[td][/td]
[/tr]
[tr]
[td]63[/td]
[td]Current[/td]
[td]11/8/2018[/td]
[td][/td]
[td]1.0000[/td]
[td]1.0000[/td]
[td]1.0000[/td]
[td]1.0000[/td]
[td]1.0260[/td]
[/tr]

[tr]
[td]64[/td]
[td]FY19[/td]
[td]09/30/2018[/td]
[td]09/30/2019[/td]
[td][/td]
[td][/td]
[td]1.0000[/td]
[td]1.0262[/td]
[td]1.0530[/td]
[/tr]

[tr]
[td]65[/td]
[td]FY20[/td]
[td]09/30/2019[/td]
[td]09/30/2020[/td]
[td][/td]
[td][/td]
[td][/td]
[td]1.0000[/td]
[td]1.0260[/td]
[/tr]

[/table]

This is another section that is used:
[table="width: 500, class: grid, align: center"]
[tr]
[td]55[/td]
[td]J/K[/td]
[td]L[/td]
[/tr]
[tr]
[td]56[/td]
[td]10/1/14[/td]
[td]FY15[/td]
[/tr]
[tr]
[td]57[/td]
[td]10/1/15[/td]
[td]FY16[/td]
[/tr]
[tr]
[td]58[/td]
[td]10/1/16[/td]
[td]FY17[/td]
[/tr]
[tr]
[td]59[/td]
[td]10/1/17[/td]
[td]FY18[/td]
[/tr]
[tr]
[td]60[/td]
[td]10/1/18[/td]
[td]FY19[/td]
[/tr]
[tr]
[td]61[/td]
[td]10/1/19[/td]
[td]FY20[/td]
[/tr]
[tr]
[td]62[/td]
[td]10/1/20[/td]
[td]FY21[/td]
[/tr]
[tr]
[td]63[/td]
[td]10/1/21[/td]
[td]FY22[/td]
[/tr]
[tr]
[td]64[/td]
[td]10/1/22[/td]
[td]FY23[/td]
[/tr]
[/table]

Now that I've bored you with tables, here's the crucial flow of data:
(1) There's a section at the top of the worksheet that allows the user to enter in detailed information about what part is being priced, all kinds of info. All we care about is a field with the quantity they are quoting, and a default lead time.
(2) I'm going to simplify some of this logic. When we quote a part, a supplier has provided us with their estimated lead time to get us the part. This lead time can vary based on the quantity; i.e. 1 part might take 20 days, but 1000 parts might take 100 days. For purposes here, we are going to assume that the lead time is the same and the price is the same for any quantity.
(3) The end user starts filling out the first table I showed you, with the quantity, UOM, base cost, lead time, and expiration date. When they put in the lead time, that changes the value for the Quote Half Life date. This is where the main problem is. If the lead time is short, the dates in the table in the range $O$56:$Q$65 are in a nice sorted order. But if the lead time is longer, as in this example, the dates are not in a nice sorted order.
(4) Here is the code in the G44 cell:
Code:
=IF(C44=0,0,IF(ISBLANK($C$42),IF(OR(AND(C$43<100,E44>=TODAY()-365-366),AND(C$43>=100,E44>=TODAY())),
C44*(
IF(VLOOKUP($O$62,$J$56:$L$64,3,1)="FY16",VLOOKUP(E44,$O$56:$T$65,5,1),
IF(VLOOKUP($O$62,$J$56:$L$64,3,1)="FY17",VLOOKUP(E44,$O$56:$V$65,7,1),
IF(VLOOKUP($O$62,$J$56:$L$64,3,1)="FY18",VLOOKUP(E44,$O$56:$X$65,9,1),
IF(VLOOKUP($O$62,$J$56:$L$64,3,1)="FY19",VLOOKUP(E44,$O$56:$Z$65,11,1),
IF(VLOOKUP($O$62,$J$56:$L$64,3,1)="FY20",VLOOKUP(E44,$O$56:$AA$65,13,1))))))),
"Needs Quote"),
C44*(
IF(VLOOKUP($O$62,$J$56:$L$64,3,1)="FY16",VLOOKUP(E44,$O$56:$T$65,5,1),
IF(VLOOKUP($O$62,$J$56:$L$64,3,1)="FY17",VLOOKUP(E44,$O$56:$V$65,7,1),
IF(VLOOKUP($O$62,$J$56:$L$64,3,1)="FY18",VLOOKUP(E44,$O$56:$X$65,9,1),
IF(VLOOKUP($O$62,$J$56:$L$64,3,1)="FY19",VLOOKUP(E44,$O$56:$Z$65,11,1),
IF(VLOOKUP($O$62,$J$56:$L$64,3,1)="FY20",VLOOKUP(E44,$O$56:$AA$65,13,1)))))))))
Essentially, it looks at whether there is a price list price in $C$42. We are not concerned with that...
All of the VLOOKUPS are taking the QuoteHalfLife Date ($O$62), and checking to see what Fiscal Year that date falls in looking at the table $J$55:$L$64. Once it knows what Fiscal Year, it looks at the Expiration Date in column E, and does a VLOOKUP against the range $O$56:$AA$65 to figure out what escalation percentage to apply. C44 is the base cost, so H44 is going to be the base cost times the escalation percent.

When the dates in $o$56:$Q$65 are out of sequence, weird results can occur.

So I'm trying to figure out how to address this issue. Rewrite that huge formula in vba? Come up with a way to resort the values in the range $0$56:$AA$65? A third option is to create a second tab, and have two versions of the worksheet - one that handles shorter lead times, one that handles longer lead times... I'm also open to any other suggestions.

Thanks!
Steve
 
Upvote 0
Steve,

Just saw this reply it is 1 am sorry for the slow response gonna take a look over the weekend and see if I can help at all....

Thanks Don
 
Upvote 0
Steve,

There is no date range in QR:62, or 63 and it is beginning to look like someone build this in 2014, for date thru 2018 and someone else had added FY19 & FY20 and perhaps copied and pasted some data and now you are having issues with the formulas.

If it worked fine for 4 years and now has issues consider using INSERT to add the rows you need above the "Quoted halflife" and make sure your date ranges are still in order from 9/30 - 9/30 of the following year and you can use CTRL-X (cut) CTRL-V (Paste) with out harming the formula excel will modify the ranges for you in most cases.

I think you will be able to get it working again.

If that is not the case and you need to re-vamp the sheet all together we can look at that as well. and for old FY14,15,16 you can 'Hide' those columns or rows just be careful deleting them that can affect the formula ranges.

HTH ~DR
 
Upvote 0
Drrellik,
I spent several hours disassembling the code for this routine, and determined that the dates definitely have to be in the right sort order to work. So what I opted to do is:
' (1) turn of screen updating...
Application.ScreenUpdating = False

'(2) delete existing table whether it exists or not
Rows("100:111").ClearContents

'(3) copy original 'table' from B39:J50 and paste as values down at rows 100...
With Worksheets("PRICING")
.Range("B39:J50").Copy
.Range("B100:J111").PasteSpecial xlPasteValues
End With

'(4) convert to a table...
ActiveSheet.ListObjects.Add(xlSrcRange, Range("B100:J111"), , xlYes).Name = "Table1"

'(5) format two date columns as date
Worksheets("PRICING").Range("C100:C111").NumberFormat = "mm/dd/yyyy"
Worksheets("PRICING").Range("D100:D111").NumberFormat = "mm/dd/yyyy"


'(6) now sort by DateRange column C100......
Dim ws As Worksheet
Set ws = ActiveSheet
Dim tbl As ListObject
Set tbl = ws.ListObjects("Table1")
Dim sortcolumn As Range
Set sortcolumn = Range("Table1[Date Range]")
With tbl.Sort
.SortFields.Clear
.SortFields.Add Key:=sortcolumn, SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With

Application.ScreenUpdating = True


Then I edited the formula for the escalated cost, and pointed it at the temporary table I created down at rows 100-110+...

I also added some code so that if the Lead Time is changed, the logic up above would automagically update the hidden table...

It actually works pretty well - at least the end-users are happy. I'm sure there may be more efficient ways to do this, but I just sort of scavenged code from here and there to accomplish what I needed.

Thanks for your help and advice.

Steve
 
Upvote 0
Glad you have a working product & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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