Solved

round down number to a list of numbers

Posted on 2014-02-19
3
250 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
3 Comments
 
LVL 23

Accepted Solution

by:
NBVC earned 500 total points
Comment Utility
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 45

Expert Comment

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now