2

I have around 8k+ rows of data that is comparing numbers, and giving a % pulled. Random example pulled out of the air...

Place Orders w/drink w/oDrink %w/oDrink
Mcdon   100    25       75       25%

My brackets are:

0-9
10-19
20-29
30-39
40-49
50-59
60-69
70-79
80-89
90+

The 25% would go into the 20-29 bracket. I am just trying to figure out if there is a function I can use to make it distinguish that?

Xiodrade
  • 113
  • 16

2 Answers2

3

Create a table with just the starting values and the desired output:

enter image description here

Then a simple VLOOKUP:

=VLOOKUP(E2*100,G:H,2)

enter image description here

Scott Craner
  • 148,073
  • 10
  • 49
  • 81
  • Just curious, as it doesn't really matter, but why did you do 0-90 for the table, instead of 0-90% and not have the `E2*100` in the formula? Just personal preference? – BruceWayne Sep 28 '17 at 15:01
  • @BruceWayne it was easier, since I had to create the table. – Scott Craner Sep 28 '17 at 15:02
1

You can also use this UDF. Please enter code below in regular module.

Function BucketNumber(rng As Range) As String
    Dim strReturn As String

    Select Case rng.Value * 100
        Case 0 To 9.9999
            strReturn = "0-9"
        Case 10 To 19.9999
             strReturn = "10-19"
        Case 20 To 29.9999
             strReturn = "20-29"
        Case 30 To 39.9999
             strReturn = "30-39"
        Case 40 To 49.9999
             strReturn = "40-49"
        Case 50 To 59.9999
             strReturn = "50-59"
        Case 60 To 69.9999
             strReturn = "60-69"
        Case 70 To 79.9999
             strReturn = "70-79"
        Case 80 To 89.9999
             strReturn = "80-99"
        Case Else
             strReturn = "90+"
    End Select
    BucketNumber = strReturn
End Function

You can now use this formula in worksheets just like regular ones.

enter image description here

Kresimir L.
  • 2,301
  • 2
  • 10
  • 22
  • 1
    Your Select Case numbers may not be valid as the OP wanted *'The 25% would go into the 20-29 bracket'*. That would be **0.25**, not **25**. –  Sep 28 '17 at 14:59