返回列表 上一主題 發帖

請教比對工作表相同的項目

回復 1# bhsm
A欄相同的值 要說明白

TOP

本帖最後由 GBKEE 於 2012-4-13 21:30 編輯

回復 3# bhsm
還有賣超一併回答   使用工作表 指令 資料  ->   合併彙算  很快的
  1. Option Explicit
  2. Sub Ex()
  3.     Dim Ar1(), Ar2(), xl As Integer, Rng As Range, xF As Range
  4.     Sheets("相同").Move Before:=Sheets(1)
  5.     ReDim  Ar1(2 To Sheets.Count)
  6.     ReDim  Ar2(2 To Sheets.Count)
  7.     For xl = 2 To Sheets.Count
  8.         With Sheets(xl)
  9.             Set Rng = .Range("A5", .[A5].End(xlDown)(1, 2))
  10.             Ar1(xl) = Rng.Address(, , xlR1C1, 1)
  11.             Set Rng = .Range("E5", .[E5].End(xlDown)(1, 2))
  12.             Ar2(xl) = Rng.Address(, , xlR1C1, 1)
  13.         End With
  14.     Next
  15.     With Sheets(1)
  16.         .Cells = ""
  17.         .[A1] = "買超"
  18.         .[A2].Consolidate Sources:=Ar1, Function:=xlCount, TopRow:=False, LeftColumn:=True, CreateLinks:=False
  19.         .[A2].Consolidate Sources:=Ar1, Function:=xlCount, TopRow:=True, LeftColumn:=True, CreateLinks:=False
  20.         .[E1] = "賣超"
  21.         .[E2].Consolidate Sources:=Ar2, Function:=xlCount, TopRow:=False, LeftColumn:=True, CreateLinks:=False
  22.         .[E2].Consolidate Sources:=Ar2, Function:=xlCount, TopRow:=True, LeftColumn:=True, CreateLinks:=False
  23.     End With
  24. End Sub
複製代碼

TOP

        靜思自在 : 時時好心就是時時好日。
返回列表 上一主題