Set d = CreateObject("Scripting.Dictionary")
<----看不懂,雖有按"f1"查CreateObject的解釋..但還是看不懂,另外Scripting.Dictionary是什麼意思
With Sheet1
d(.[A1] & .[B1]) = .[C1]<----不懂d(.[A1] & .[B1]) 這個寫法的意思~~~
For Each a In .Range(.[A2], .[A65536].End(xlUp))
d(a & a.Offset(, 1)) = d(a & a.Offset(, 1)) + a.Offset(, 2)<----不懂d(a & a.Offset(, 1)) 這個寫法的意思~~~
Next
End With
With Sheet2
.Columns("A:B") = ""
.[A1].Resize(d.Count, 1) = Application.Transpose(d.keys)
.[B1].Resize(d.Count, 1) = Application.Transpose(d.items)
<----Transpose(d.keys)與Transpose(d.items)是什麼意思
End With作者: oobird 時間: 2010-9-13 17:13
Set d = CreateObject("Scripting.Dictionary")
調用字典物件
d(.[A1] .[B1]) = .[C1]<----這是錯誤的寫法
d(a a.Offset(, 1)) = ...<----這行也是錯誤的
若是合并兩個儲存格應該用"&"符號連起來!作者: oak0723-1 時間: 2010-9-13 19:25
Set d = CreateObject("Scripting.Dictionary")
With Sheet1
d(.[A1] & .[B1]) = .[C1]
For Each a In .Range(.[A2], .[A65536].End(xlUp))
d(a & a.Offset(, 1)) = d(a & a.Offset(, 1)) + a.Offset(, 2)
Next
End With
With Sheet2
.Columns("A:B") = ""
.[A1].Resize(d.Count, 1) = Application.Transpose(d.keys)
.[B1].Resize(d.Count, 1) = Application.Transpose(d.items)
End With作者: kimbal 時間: 2010-9-13 19:58
可以說一下 SHEET1 的 A, B, C 3欄是什麼嗎
如果設一個例的話
A欄是牌子, B欄是貨名, C是件數
假設sheet1是
A B C
1 牌子 貨名 件數
2 A Z 1
3 A Y 2
4 B X 3
5 A Z 4
運行後sheet2:
A B
1 牌子貨名 件數
2 AZ 5
3 AY 2
4 BX 3
字典物件可以看成是一個獨立隱藏的excel頁,上面只有key(鍵)和item(值)兩個欄位
如
d("M")=1 -> 把M鍵的值設成數字1
d("N")="c" ->把N鍵有的值設成字"c"
上面兩行會產生下面4個"格子"
M 1
N c