代码如下,效果如图:Subisheet()Dimx,y,z,nDimar(1To10000,1To4),br,crz=Range("a3").End(xlToRight).Columnbr=Range("a3").Resize(1,z)cr=Range("a2:d2")Forx=1ToUBound(ar,1)Fory=1To4n=n+1Ifn>zThenGoTo100ar(x,y)=br(1,n)NextNext100:Range("a5").Resize(1,4)=crWithRange("a6").Resize(n/4,4)=ar.CurrentRegion.Borders.LineStyle=True.CurrentRegion.HorizontalAlignment=xlCenterEndWithEndSub