Solved

# round down number to a list of numbers

Posted on 2014-02-19
257 Views
I have a spreadsheet that contains some values in column A.  I need to round those numbers down.  The catch is that I need to round them down to a set of numbers in column B.  I listed the expected results in column D.  I need help coming up with a formula to do the calculation.  Thank you!
rounddownlist.xlsx
0
Question by:colonialiu20
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 23

Accepted Solution

NBVC earned 500 total points
ID: 39870806
Assuming column B is in ascending order per your sample, try:

=LOOKUP(2,1/(\$B\$2:\$B\$36<=A2),\$B\$2:\$B\$36)

copied down

this looks for the last time a number in column B is less than or equal to the value in column.  This would be equivalent to the rounded down value of column A according to column B options.
0

LVL 47

Expert Comment

ID: 39870891
The above probably works and if so it's better but you can also add a module to your workbook and add this UDF

``````Function RoundToList(r As Variant) As Variant
Dim lngRow As Long
Dim lngLastRow As Long

lngLastRow = Range("B65536").End(xlUp).Row

For lngRow = lngLastRow To 2 Step -1
If Cells(lngRow, 2).Value < r Then
RoundToList = Cells(lngRow, 2).Value
Exit For
End If
Next

End Function
``````

Then in D2 put =RoundToList(A2) and copy down.
0

LVL 50

Expert Comment

ID: 39871042
I don't think your LOOKUP needs to be as complicated as NBVC suggests -  this version should do what you want in D2 copied down:

=LOOKUP(A2,B\$2:B\$36)

regards, barry
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
###### Suggested Courses
Course of the Month4 days, 17 hours left to enroll