若有空行 下列開頭單引號刪除 Dim RowsEnd As Long '最後一行 RowsEnd = 100 '最後一行(這行漏加) For i = 1 To RowsEnd 下列開頭 + 單引號 For i = 1 To ActiveCell.CurrentRegion.Columns(ColNo).Rows.Count
虛線以下 VBA程式 ----------------------------------------------------------------------- Dim i As Long '流水號 Dim ColNo As Integer '搜尋欄位 Dim ColCou As Integer '計算欄位 Dim Total As Integer '總計 'Dim RowsEnd As Long '最後一行 Dim FindStr As String '搜尋字串
Total = 0 'For i = 1 To RowsEnd For i = 1 To ActiveCell.CurrentRegion.Columns(ColNo).Rows.Count If Cells(i, ColNo) = FindStr Then Total = Total + Cells(i, ColCou) End If Next i MsgBox FindStr & " 總計 : " & Total