sub test()
dim n,m,x,y as long
dim rw() as long
dim str() as string
n=sheets(1).usedrange.rows.count
redim rw(1 to n) as long
m=1
for x= 1 to n
rw(x)=sheets(1).cells(x,"D")
str(x)=sheets(1).cells(x,"A")
for y= 1 to rw(x)
sheets(1).cells(m+y-1,"E")=str(x)
next y
m=m+rw(x)
next x
end sub
追问
什么情况
追答我设置的n为你表1 所有使用过的行数。。。。这个错误是数组的指针变量超出数组定义的范围,你可以监测一下 x与n的值 ,应该就能改好了。