|
- Sub Macro1()
- Dim arr, d, i&
- Set d = CreateObject("scripting.dictionary")
- arr = Range("a1").CurrentRegion
- n = UBound(arr): x = [e1]
- [f5] = ""
- For i = UBound(arr) - 1 To 1 Step -1
- If arr(i, 1) = arr(n, 1) Then d(i) = ""
- Next
- zdh = n: h = n - x + 1
- For Each a In d.keys
- If Abs(h - a) < zdh Then zdh = Abs(h - a)
- Next
- If Range("a1").Resize(n - 1).Find(arr(n, 1)) Is Nothing Then Exit Sub
- s = IIf(d.exists(zdh + h), h + zdh, h - zdh)
- s2 = s + 1
- Do
- x1 = arr(s, 1): x2 = arr(s + 1, 1)
- yh = yh + x1 + x2 '右边和
- y = y + 1 '右边计数
- s = s + 2
- Loop Until s >= n
- Do
- x1 = arr(s2, 1): x2 = arr(s2 + 1, 1)
- zh = zh + x1 + x2 '左边和
- z = z + 1 '左边计数
- s2 = s2 + 2
- Loop Until s2 >= n
- [f5] = (zh + yh) / (y + z)
- End Sub
复制代码 |
评分
-
查看全部评分
|