今天来看个练习题 假设有这样一组数据,如何根据特定的条件进行排序呢? 方法1: SELECT 学历 FROM [Sheet1$] GROUP BY 学历 ORDER BY COUNT(学历) DESC,学历 方法2: =INDEX(B:B,100-MOD(LARGE(IF(MATCH(B2:B31,B:B,)=ROW(2:31),COUNTIF(B2:B31,B2:B31)/1%-ROW(2:31)),ROW(1:7)),100)) 方法3: Sub test() arr = Range('A1').CurrentRegion Set d = CreateObject('scripting.dictionary') For i = 1 To UBound(arr) d(arr(i, 2)) = d(arr(i, 2)) 1 Next s_d = d.keys s_i = d.items For j = 1 To UBound(s_i) For j1 = j 1 To UBound(s_i) temp = s_i(j): temp2 = s_d(j) temp1 = s_i(j1): temp3 = s_d(j1) If temp1 > temp Then s_i(j) = temp1 s_i(j1) = temp s_d(j) = temp3 s_d(j1) = temp2 End If Next Next [f3].Resize(d.Count, 1) = Application.Transpose(s_d) End Sub |
|