按ALT+F11,在左边点右键,插入一个模块,输入如下代码,按F5。SubM1()DimEndRow,Arr1,Temp1EndRow=Cells(65536,1).End(xlUp).RowArr1=Range(Cells(1,1),Cells(EndRow,1))Temp1=0Fori=2ToUBound(Arr1,1)IfArr1(i,1)""ThenTemp1=Temp1+Arr1(i,1)ElseArr1(i,1)=Temp1Temp1=0EndIfNextRange(Cells(1,1),Cells(EndRow,1))=Arr1EndSub