[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

round down number to a list of numbers

Posted on 2014-02-19
3
Medium Priority
?
260 Views
Last Modified: 2014-02-19
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
Comment
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
  • Learn & ask questions
3 Comments
 
LVL 23

Accepted Solution

by:
NBVC earned 2000 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 49

Expert Comment

by:Martin Liss
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

Open in new window


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

Expert Comment

by:barry houdini
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question