作者:乔山办公网日期:
返回目录:excel表格制作
选中区域——数据——排序(正序,逆序),如图:
选择参与排序数据所在列,然后按“升序”或“降序”排序,并可以选择“是否扩展选定区域”对区域外的其他数据进行联动。
首先,按下ALT+F11进入VBA窗口进行自定义函数e68a847a64332.进入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
思路是按姓名排序,然后设置超链接,你一点序号就会跳到那些单元格。
如果有必要可将你表格发我邮箱里,我给你做一个看。
希望能帮到你!