1. 代码如下:Sub add()Dim i, aFor i = 2 To 99a = Range("B" & i)If a > 0 Then a = a + 1: Range("B" & i) = aNext iEnd Sub2. 根据你的实际行号范围,调整for循环的最大值(99)。