sub demo()
set d1 = CreateObject("Scripting.Dictionary")
set d2 = CreateObject("Scripting.Dictionary")
with sheets(1)
a=.[a1].CurrentRegion
for i=2 to ubound(a)
d1(a(i,2)) = d1(a(i,2)) +1
next
end with
with sheets(2)
b=.[a1].CurrentRegion
for i=2 to ubound(b)
d2(b(i,1)) = d2(b(i,1))&","&b(i,2)
n = n + d1(b(i,1))
next
end with
redim c(1 to n + ubound(a)-1,3)
for i=2 to ubound(a)
m = m + 1
c(m,1) = a(i,1)
c(m,2) = a(i,2)
c(m,3) = a(i,3)
b = split(d2(a(i,2)),",")
for k=1 to ubound(b)
m=m+1
c(m,2) = b(k)
c(m,3) = "取消"
next
next
sheets(1).[a2].resize(m,3)=c
end sub
|