分别查找本和累两列中绝对值最大值,并输出各自最大值对应的点号
查找本和累两列中各自绝对值最大值及对应第一列的点号,初步完成查找最大值功能,如何和第一列点号匹配,求助大神,使用vlookup吗
Public Sub 统计分析()Dim arr1() As String Dim arr2() As String n = Selection.Count / 2 ReDim arr1(1 To n, 1 To 1) ReDim arr2(1 To n, 1 To 1) max1 = 0 max2 = 0 For i = 1 To n arr1(i, 1) = Format(Selection.Cells(i, 1), "0.00") arr2(i, 1) = Format(Selection.Cells(i, 2), "0.00") Next For i = 1 To n If max1 < Abs(arr1(i, 1)) Then max1 = arr1(i, 1) If max2 < Abs(arr2(i, 1)) Then max2 = arr2(i, 1) Next MsgBox "本次最大值:" & max1 & " 点号:" & i & Chr(10) & "累积最大值:" & max2 & " 点号:" & j, vbOKOnly, "提示" End Sub
|