|
本帖最后由 我是来讨说法的 于 2018-9-29 16:48 编辑
这有什么难度,一个字典就搞的了,如果没人弄了,我来弄开一发
- Function calc(rng As Range, n)
- Dim arr As Variant
- Dim dic As Object
- Dim k As Integer
- Dim temp As String
- Set dic = CreateObject("Scripting.Dictionary")
- k = 1
- arr = rng.Value
- dic(arr(UBound(arr), 2)) = ""
- For i = UBound(arr) - 1 To 1 Step -1
- For j = 1 To 2
- If dic.Count = n Then
- Exit For
- Else
- dic(arr(i, j)) = ""
- End If
- Next
- Next
- If dic.Count = n Then
- calc = Join(dic.keys, " ")
- Else
- calc = "#NA"
- End If
- End Function
复制代码 公式有2个参数,第一个参数是数据的选区,第二个是你要返回的个数,你想要返回几个,就填几
|
|