標題:
如何設定自動加總vba程式
[打印本頁]
作者:
agwhk
時間:
2013-10-5 10:14
標題:
如何設定自動加總vba程式
請教如下圖所示vba程式怎樣寫?
謝謝 !!!
[attach]16241[/attach]
作者:
kimbal
時間:
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
複製代碼
作者:
agwhk
時間:
2013-10-9 11:15
謝謝 kimbal 大哥 , 正是我須要的程式非常感謝!!!
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)