sub 宏1()
dim arr,arr2,n,i,j,k,t,i2
n=0'計算總行數
for each t in array("a","b","c")
n=n+sheets("匯總" & t).usedrange.rows.count
next t
redim arr(1 to n,1 to 4) '結果數組
n=0'結果數組行數
for each t in array("a","b","c")
arr2=sheets("匯總" & t).usedrange
j=asc(t)-asc("a")+2'數據在結果表的列
k=8 '數據在原始表的列
for i2=2 to ubound(arr2)
for i=1 to n
if arr(i,1)=arr2(i2,1) then exit for
next i
if arr(i,1)<>arr(i2,1) then
n=n+1
i=n
arr(i,1)=arr(i2,1)
end if
arr(i,j)=arr2(i2,k)
next i
next t
'保存結果
sheeta("匯總").range("a2").resize(n,4)=arr
end sub