搜索

excel 排序功能,如何用??????????????????急急急

发布网友 发布时间:2022-02-25 05:10

我来回答

1个回答

热心网友 时间:2022-02-25 06:40

首先,按下ALT+F11进入VBA窗口进行自定义函数.进入VBA窗口后.菜单插入-模块.然后复制下列代码,关闭.

Public Function order(n As Long) As String
Dim a As Integer
Dim b() As Integer
Dim c As Integer
Dim d() As Integer
Dim sum As String
a = Len(n)
ReDim b(1 To a) As Integer
ReDim d(1 To a) As Integer
c = 0
For x = 1 To a
b(x) = Val(Mid(n, x, 1))
Next
For x = 1 To a
For y = 1 To a
If b(x) >= b(y) Then
c = c + 1
End If
Next
d(c) = b(x)
c = 0
Next
For x = 1 To a
sum = sum & d(x)
Next
order = sum
End Function

然后.例如你的数据在A1:A100
那在B1输入=ORDER(A1),然后后向下填充公式到B100,B列就是你要的数据.
**********

改了一下下

Public Function order(n As String) As String
Dim c As Integer
Dim b() As Integer
Dim d() As Integer
Dim sum As String
ReDim b(1 To Len(n)) As Integer
ReDim d(1 To Len(n)) As Integer
c = 0
For x = 1 To Len(n)
b(x) = Val(Mid(n, x, 1))
Next
For x = 1 To Len(n)
For y = 1 To Len(n)
If b(x) >= b(y) Then
c = c + 1
End If
Next
d(c) = b(x)
c = 0
Next
For x = 1 To Len(n)
sum = sum & d(x)
Next
order = sum
End Function
声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com
Top