- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 104
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-4-30
               
|
4#
發表於 2011-11-8 22:26
| 只看該作者
回復 3# 317
用排序可以嗎?- Sub CopyData()
- Dim 列 As Integer
- Dim 貨物編號 As String
- Dim 貨物名稱 As String
- Dim 類型 As String
- Dim 數量 As Integer
- Set d = CreateObject("Scripting.Dictionary")
- 列 = ActiveCell.Row
- 選擇用途 = Cells(列, 2)
- 貨物編號 = Cells(列, 3)
- 貨物名稱 = Cells(列, 4)
- 類型 = Cells(列, 5)
- 數量 = Cells(列, 8)
- Windows("b.xls").Activate
- With Workbooks("b.xls").Sheets("sheet1")
- .Select
- For Each a In .[AB3:AB6]
- d(a.Value) = a.Interior.ColorIndex
- Next
- Set a = .[A65536].End(xlUp).Offset(1, 0).Resize(, 5)
- a.Interior.ColorIndex = d(選擇用途)
- a.Value = Array(選擇用途, 貨物編號, 貨物名稱, 類型, 數量)
- a.Select
- .Range(.[A2:E2], .[A2:E2].End(xlDown)).Sort key1:=.[A2], Header:=xlYes
- End With
- End Sub
複製代碼 |
|