- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
5#
發表於 2012-4-13 21:18
| 只看該作者
本帖最後由 GBKEE 於 2012-4-13 21:30 編輯
回復 3# bhsm
還有賣超一併回答 使用工作表 指令 資料 -> 合併彙算 很快的- Option Explicit
- Sub Ex()
- Dim Ar1(), Ar2(), xl As Integer, Rng As Range, xF As Range
- Sheets("相同").Move Before:=Sheets(1)
- ReDim Ar1(2 To Sheets.Count)
- ReDim Ar2(2 To Sheets.Count)
- For xl = 2 To Sheets.Count
- With Sheets(xl)
- Set Rng = .Range("A5", .[A5].End(xlDown)(1, 2))
- Ar1(xl) = Rng.Address(, , xlR1C1, 1)
- Set Rng = .Range("E5", .[E5].End(xlDown)(1, 2))
- Ar2(xl) = Rng.Address(, , xlR1C1, 1)
- End With
- Next
- With Sheets(1)
- .Cells = ""
- .[A1] = "買超"
- .[A2].Consolidate Sources:=Ar1, Function:=xlCount, TopRow:=False, LeftColumn:=True, CreateLinks:=False
- .[A2].Consolidate Sources:=Ar1, Function:=xlCount, TopRow:=True, LeftColumn:=True, CreateLinks:=False
- .[E1] = "賣超"
- .[E2].Consolidate Sources:=Ar2, Function:=xlCount, TopRow:=False, LeftColumn:=True, CreateLinks:=False
- .[E2].Consolidate Sources:=Ar2, Function:=xlCount, TopRow:=True, LeftColumn:=True, CreateLinks:=False
- End With
- End Sub
複製代碼 |
|