返回列表 上一主題 發帖

[發問] 請問如何將這句+{sum(if......,if......,))}, 用在Macro裡面??

本帖最後由 GBKEE 於 2011-12-24 17:46 編輯

回復 1# idsmchow
自動篩選
  1. Option Explicit
  2. Sub Ex()
  3.     Dim C As Integer
  4.     C = 10
  5.     With Sheets("Report")
  6.         Do Until .Cells(C, "B") = ""
  7.             If .Cells(C, "A") = "" Then
  8.                 .Range(.Cells(C, "E"), .Cells(C, "G")) = 0
  9.             ElseIf .Cells(C, "A") = "Y" Then
  10.                 Sheets("Data").Cells.AutoFilter
  11.                 Sheets("Data").Cells.AutoFilter 1, "A"
  12.                 Sheets("Data").Cells.AutoFilter 2, .Cells(C, "B")
  13.                 .Cells(C, "E") = Application.Sum(Sheets("Data").Columns(3).SpecialCells(xlCellTypeVisible))
  14.                 Sheets("Data").Cells.AutoFilter
  15.                 Sheets("Data").Cells.AutoFilter 1, "B"
  16.                 Sheets("Data").Cells.AutoFilter 2, .Cells(C, "B")
  17.                 .Cells(C, "F") = Application.Sum(Sheets("Data").Columns(3).SpecialCells(xlCellTypeVisible))
  18.                 .Cells(C, "G") = .Cells(C, "E") + .Cells(C, "F")
  19.             End If
  20.             C = C + 1
  21.         Loop
  22.     End With
  23.     Sheets("Data").AutoFilterMode = False
  24. End Sub
複製代碼

TOP

        靜思自在 : 【時間如鑽石】時間對一個有智慧的人而言,就如鑽石般珍貴;但對愚人來說,卻像是一把泥土,一點價值也沒有。
返回列表 上一主題