将%s放入0-9 10-19等括号

时间:2017-09-28 14:41:02

标签: excel excel-formula

我有大约8k +行数据正在比较数字,并给出%拉。 随机的例子拉出来......

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

我的括号是:

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

25%将进入20-29支架。我只是想弄清楚是否有一个我可以用来区分它的功能?

2 个答案:

答案 0 :(得分:3)

创建一个只包含起始值和所需输出的表:

enter image description here

然后是一个简单的VLOOKUP:

data-type

enter image description here

答案 1 :(得分:1)

您也可以使用此UDF。请在常规模块中输入以下代码。

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

现在,您可以像常规工具一样在工作表中使用此公式。

enter image description here