|
参与一下。。。
- Sub ykcbf() '//2024.8.23
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("練習問題3")
- r = .Cells(Rows.Count, 2).End(3).Row
- arr = .[a1].Resize(r, 10)
- For i = 1 To r
- If Val(arr(i, 1)) Then k = k + 1: d(k) = i
- Next
- For k = 1 To d.Count
- r1 = d(k)
- If k = d.Count Then r2 = r Else r2 = d(k + 1) - 1
- sum1 = 0: sum2 = 0
- For j = 3 To 9
- For i = r1 + 1 To r2 Step 4
- If .Cells(i, j) <> Empty Then
- sum1 = sum1 + .Cells(i + 1, j).Value
- sum2 = sum2 + .Cells(i + 2, j).Value
- .Cells(i + 3, j).Value = .Cells(i + 1, j).Value / .Cells(i + 2, j).Value
- End If
- Next
- Next
- .Cells(r2 - 2, 10) = sum1
- .Cells(r2 - 1, 10) = sum2
- .Cells(r2, 10) = sum1 / sum2
- Next
- End With
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
|