Excel 求助:VBA求满足条件的最大值怎么写
3个回答
展开全部
例:求A列中小于1500的最大值,用Application.Evaluate 方法,调用Excel数组函数:
Sub max()
Dim max_if
max_if = Application.Evaluate("MAX(if((A:A<1500),A:A))")
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Sub lqxs()
Dim Arr, i&, d
Set d = CreateObject("Scripting.Dictionary")
Sheet1.Activate
Arr = [a1].CurrentRegion
For i = 2 To UBound(Arr)
If Not d.exists(Arr(i, 2)) Then
d(Arr(i, 2)) = Arr(i, 3)
Else
If d(Arr(i, 2)) < Arr(i, 3) Then d(Arr(i, 2)) = Arr(i, 3)
End If
Next
[f2].Resize(d.Count, 1) = Application.Transpose(d.keys)
[g2].Resize(d.Count, 1) = Application.Transpose(d.items)
End Sub
Dim Arr, i&, d
Set d = CreateObject("Scripting.Dictionary")
Sheet1.Activate
Arr = [a1].CurrentRegion
For i = 2 To UBound(Arr)
If Not d.exists(Arr(i, 2)) Then
d(Arr(i, 2)) = Arr(i, 3)
Else
If d(Arr(i, 2)) < Arr(i, 3) Then d(Arr(i, 2)) = Arr(i, 3)
End If
Next
[f2].Resize(d.Count, 1) = Application.Transpose(d.keys)
[g2].Resize(d.Count, 1) = Application.Transpose(d.items)
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询