Foxtable(狐表)用户栏目专家坐堂 → [求助]单元格 多值字段的排序


  共有3340人关注过本帖平板打印复制链接

主题:[求助]单元格 多值字段的排序

帅哥哟,离线,有人找我吗?
danfero
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:313 积分:2302 威望:0 精华:0 注册:2014/4/11 14:35:00
[求助]单元格 多值字段的排序  发帖心情 Post By:2014/6/25 12:31:00 [只看该作者]

请问怎么排序?怎么修改这段VBA代码?
有人在Excel做了个自定义函数,可以达到此结果,在狐表怎么做,附上excel自定义

Public Function px(rng As Range)
If rng.Count <> 1 Then px = "err": Exit Function
Dim tempstr() As String
tempstr = Split(rng.Value, " ")
Dim cont As Integer, tempv As String, returnv As String

If UBound(tempstr) >= 0 Then cont = UBound(tempstr) + 1
If cont > 0 Then
    cont = cont - 1
    For i = 0 To cont - 1
        For j = i + 1 To cont
            If tempstr(j) < tempstr(i) Then
                tempv = tempstr(j)
                tempstr(j) = tempstr(i)
                tempstr(i) = tempv
            End If
        Next
    Next
    i = 0
    For i = 0 To cont
        If i = 0 Then
            returnv = tempstr(i)
        Else
            returnv = returnv & " " & tempstr(i)
        End If
    Next
End If
px = returnv
End Function


图片点击可在新窗口打开查看此主题相关图片如下:排序.jpg
图片点击可在新窗口打开查看

 回到顶部