- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
本帖最後由 GBKEE 於 2011-12-24 17:46 編輯
回復 1# idsmchow
自動篩選- Option Explicit
- Sub Ex()
- Dim C As Integer
- C = 10
- With Sheets("Report")
- Do Until .Cells(C, "B") = ""
- If .Cells(C, "A") = "" Then
- .Range(.Cells(C, "E"), .Cells(C, "G")) = 0
- ElseIf .Cells(C, "A") = "Y" Then
- Sheets("Data").Cells.AutoFilter
- Sheets("Data").Cells.AutoFilter 1, "A"
- Sheets("Data").Cells.AutoFilter 2, .Cells(C, "B")
- .Cells(C, "E") = Application.Sum(Sheets("Data").Columns(3).SpecialCells(xlCellTypeVisible))
- Sheets("Data").Cells.AutoFilter
- Sheets("Data").Cells.AutoFilter 1, "B"
- Sheets("Data").Cells.AutoFilter 2, .Cells(C, "B")
- .Cells(C, "F") = Application.Sum(Sheets("Data").Columns(3).SpecialCells(xlCellTypeVisible))
- .Cells(C, "G") = .Cells(C, "E") + .Cells(C, "F")
- End If
- C = C + 1
- Loop
- End With
- Sheets("Data").AutoFilterMode = False
- End Sub
複製代碼 |
|