EXCEL如何按顺序提取大于0的数
答案:1 悬赏:30 手机版
解决时间 2021-03-20 19:38
- 提问者网友:椧運幽默
- 2021-03-20 01:06
EXCEL如何按顺序提取大于0的数
最佳答案
- 五星知识达人网友:执傲
- 2021-03-20 01:12
这个可以通过vba实现,代码如下:
Sub 取值并排序()
Dim shu(1 To 25) As Integer
Dim rng As Range
Dim i, j, k, l As Integer
i = 1
For Each rng In Range("a1:e5")
If rng.Value > 0 Then
shu(i) = rng.Value
i = i + 1
End If
Next rng
For j = 1 To UBound(shu) - LBound(shu)
For k = 1 To UBound(shu) - LBound(shu)
If shu(k) > shu(k + 1) Then
l = shu(k)
shu(k) = shu(k + 1)
shu(k + 1) = l
End If
Next k
Next j
Range("a7:y7") = shu
For i = 0 To 24
If Range("a7") = 0 Then
Range("a7").Delete
Else
Exit For
End If
Next i
End Sub
Sub 取值并排序()
Dim shu(1 To 25) As Integer
Dim rng As Range
Dim i, j, k, l As Integer
i = 1
For Each rng In Range("a1:e5")
If rng.Value > 0 Then
shu(i) = rng.Value
i = i + 1
End If
Next rng
For j = 1 To UBound(shu) - LBound(shu)
For k = 1 To UBound(shu) - LBound(shu)
If shu(k) > shu(k + 1) Then
l = shu(k)
shu(k) = shu(k + 1)
shu(k + 1) = l
End If
Next k
Next j
Range("a7:y7") = shu
For i = 0 To 24
If Range("a7") = 0 Then
Range("a7").Delete
Else
Exit For
End If
Next i
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯