- 帖子
- 472
- 主題
- 5
- 精華
- 0
- 積分
- 485
- 點名
- 0
- 作業系統
- Windows
- 軟體版本
- MS Office
- 閱讀權限
- 100
- 性別
- 男
- 來自
- 香港
- 註冊時間
- 2010-7-4
- 最後登錄
- 2014-12-28

|
2#
發表於 2013-10-6 10:46
| 只看該作者
回復 1# agwhk - Sub test()
- Dim firstPos As Long, currRow As Long, lastrow As Long
- Dim startRng As Range
-
- Set startRng = ActiveSheet.Range("B3")
-
- lastrow = Range("B65536").End(xlUp).Row + 1
- currRow = 0
-
- Do
- With startRng
- If UCase(Left(.Offset(currRow, 0).Offset(0, -1), 8)) = "SUBTOTAL" Then
- .Offset(currRow, 0).Value = Application.WorksheetFunction.Sum(Range(.Offset(firstPos, 0), .Offset(currRow - 1, 0)))
- firstPos = currRow + 1
- End If
- End With
- currRow = currRow + 1
-
- Loop While startRng.Offset(currRow).Row <= lastrow
- End Sub
複製代碼 |
|