代碼如下:
OptionExplicitSubYgB()
Dimarr,i,i2,j,k,m,n,cAsRange
arr=Selection
i=Selection.Cells(1,1).Row
j=Selection.Cells(1,1).Column
n=0
Fork=1ToUBound(arr)
Ifn0Then
Ifarr(k,1)>n+1Then
Cells(i2,1).Resize(arr(k,1)-n-1,1).EntireRow.Insert
ForEachcInCells(i2,1).Resize(arr(k,1)-n-1,1).Cells
n=n+1
c.Value=n
i2=i2+1
Nextc
EndIf
i2=i2+1
Else
i2=i+k
EndIf
n=arr(k,1)
Nextk
EndSub
執(zhí)行的拷屏如下: