发布网友 发布时间:2024-05-12 14:52
共1个回答
热心网友 时间:2024-06-01 21:49
代码
Function max6or3(rng As Range, mode As Integer) As String
Dim i As Integer, j As Integer
Dim MySum, myMax, myI As Integer
Dim V(1 To 12)
i = 1
For Each r In rng
V(i) = r.Value
i = i + 1
Next r
For i = 1 To 12 - mode + 1
MySum = 0
For j = 0 To mode - 1
MySum = MySum + V(i + j)
Next j
If MySum > myMax Then
myMax = MySum
myI = i
End If
Next
max6or3 = (i - 1) & "-" & (i + mode - 2)
End Function