如何用VBA将excel中的一列值进行从小到大排序,然后显示到excel上喔??
PublicSubtt()Dima(2To100)AsDoubleDimiAsInteger,jAsInteger,nAsIntegerDimtAsDoubleFori=...
Public Sub tt()
Dim a(2 To 100) As Double
Dim i As Integer, j As Integer, n As Integer
Dim t As Double
For i = 0 To n - 1
For j = i + 1 To n - 1
If a(i) > a(j) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next j
Next i
For i = 0 To n - 1
Next
End Sub
我的从小到大排序程序是这样的~~如何用VBA将excel中的一列值进行从小到大排序,然后显示到excel上喔?? 展开
Dim a(2 To 100) As Double
Dim i As Integer, j As Integer, n As Integer
Dim t As Double
For i = 0 To n - 1
For j = i + 1 To n - 1
If a(i) > a(j) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next j
Next i
For i = 0 To n - 1
Next
End Sub
我的从小到大排序程序是这样的~~如何用VBA将excel中的一列值进行从小到大排序,然后显示到excel上喔?? 展开
展开全部
假设源数据在A列,排好的数据输出到B列,代码如下:
Sub s()
Dim arr, i, j, n, tmp
n = Cells(Rows.Count, 1).End(3).Row
arr = [a1].Resize(n)
For i = 2 To n
For j = n To i Step -1
If arr(j, 1) < arr(j - 1, 1) Then
tmp = arr(j, 1)
arr(j, 1) = arr(j - 1, 1)
arr(j - 1, 1) = tmp
End If
Next
Next
[b1].Resize(n) = arr
End Sub
展开全部
Columns("A:A").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlPinYin, DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlPinYin, DataOption1:=xlSortNormal
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询