慕尼黑8549860
这个问题可以使用字典和数组两种编程方式,字典的程序简单一点,数组运行效率更高一点点,但是逻辑稍微复杂一点,下面是数组的写法:sub 宏1()dim arr,arr2,n,i,j,k,t,i2n=0'计算总行数for each t in array("a","b","c")n=n+sheets("汇总" & t).usedrange.rows.countnext tredim arr(1 to n,1 to 4) '结果数组n=0'结果数组行数for each t in array("a","b","c")arr2=sheets("汇总" & t).usedrangej=asc(t)-asc("a")+2'数据在结果表的列k=8 '数据在原始表的列for i2=2 to ubound(arr2)for i=1 to nif arr(i,1)=arr2(i2,1) then exit fornext iif arr(i,1)<>arr(i2,1) thenn=n+1i=narr(i,1)=arr(i2,1)end ifarr(i,j)=arr2(i2,k)next inext t'保存结果sheeta("汇总").range("a2").resize(n,4)=arrend sub