I am working with a data table that contains two columns ( Max Room Height, # of bulbs). Intent is to create a formula which provides the output on # of bulbs to use after the user inputs room height. Here’s the trick, room height number that user inputs can be a random number, and could lie between two max room heights. For example , room height data is available as 10 feet, 12 feet, 14 feet, 16 feet and the and user inputs room height as 15 feet, formula should be able to pick up the # of bulbs corresponding to 16 feet height.
标签:
excel-formula
相关问题
- Excel formula in VBA code
- Excel named ranges to make incrementing headers an
- How can I use the WEEKNUM function in a statement
- SUMIF(S) with VLOOKUP
- Turn a value range in a cell into a comma separate
相关文章
- How do you figure out the MEDIAN of a column takin
- Excel expression to copy rows but remove blank row
- Excel formula in counting distance between a speci
- How can I write an excel formula to return a value
- How do I fuzzy match just adjacent cells?
- Google spreadsheet relative row numbering + skip e
- How to get the formula cell value(data) using apac
- How do I prevent Excel from automatically replicat
You can try using some of the built-in Excel functions to determine the number of bulbs to use based on the room height. Here's an example using
INDEX(...)
,MATCH(...)
, andMIN(...)
:I do not have access to Excel at the moment, but this worked in LibreOffice Calc v5.1.6.2. Excel seems to have comparable functions.
Long Winded Explanation
Read on, in case a picture is not worth a thousand words!
Table/Data Configuration
Formula/Calculation
Let's break down the formula that will go into the Column B cells. I left the text for the formula in Column C. You'll notice that only the first parameter of the
MIN(...)
function changes for each row. The rest of the formula is the same for each row.Using row 2 as an example, we make use of 3 functions, nested together:
MIN(A2,E2)
- We want to make sure the room height falls within our handled range. This works in conjunction with the the arbitrary upper bound of 10000 that was added to Column E. If we didn't force the data to fit within the upper boundary, we'd probably see some kind of error if the user exceeded the largest value specified in Column E.MATCH(MIN(A2,E2),E2:E6,-1)
- Essentially, this function finds the height range boundary under which the user entered data falls. This function has three parameters. The first is the user entered data (or the arbitrary upper bound)...MIN(A2,E2)
for this row. The second is the height range boundaries (in descending order)...E2:E6
. The third is the matching type...-1
. The matching type of -1 means "search a descending list of values and stop when your given value (i.e. the first parameter) is equal to or less than a value in the descending list". If the first item in the descending list meets the criteria, theMATCH(...)
function returns an index of 1. If the second item in the descending list meets the criteria, the function returns an index of 2... etc.INDEX(F2:F6,MATCH(MIN(A2,E2),E2:E6,-1))
- This function essentially looks up our "answer" for the user's input. We found the "index" or "list position" of the height range for the user's input using theMATCH(...)
function and we created our table such that the bulb-count for each height range is in the same row (i.e. it has the same "index" or "list position"). TheINDEX(...)
function accepts two parameters. The first is the range of cells containing the "answers"...F2:F6
. The second parameter is the index or list position from the answer cell range that we want to return (i.e. the results of ourMATCH(...)
function). So if ourMATCH(...)
function call returns "1", the first cell from the F2:F6 range will be returned (i.e. F2 - Use the Sun!). If ourMATCH(...)
function call returns "2", the second cell from the F2:F6 range will be returned (i.e. F3 - 4 bulbs)... etc.There might be better solutions out there depending on the version of Excel you are using. According to the Office documentation as of this writing, the functions used here should be valid for Excel 2007 through 2016.