要用vba实现,A1:A10=1-10, 在A1:A10中,找出第二大的数字,并返回行号.
2个回答
展开全部
Option Explicit
Sub large2()
Dim arr As Variant, brr As Variant, tmp As Variant
Dim i As Integer, j As Integer
arr = Application.Transpose(ActiveSheet.[a1:a10])
brr = arr
For i = 1 To UBound(brr) - 1
For j = i + 1 To UBound(brr)
If brr(i) < brr(j) Then
tmp = brr(i)
brr(i) = brr(j)
brr(j) = tmp
End If
Next j
Next i
For i = 1 To UBound(arr)
If arr(i) = brr(2) Then
MsgBox i
Exit Sub
End If
Next i
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询