Sub 选择性粘贴() Selection.Copy Dim x, y x = Selection.Row() '行坐标 y = Selection.Column() '列坐标 Dim nx, ny nx = 1 '粘贴是所要移动的行数 ny = 1 '粘贴是所要移动的列数 Cells(x+nx,y+ny).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd, SkipBlanks _ :=False, Transpose:=False End Sub
1. 代码如下: Sub add() Dim i, a For i = 2 To 99 a = Range("B" & i) If a > 0 Then a = a + 1: Range("B" & i) = a Next i End Sub 2. 根据你的实际行号范围,调整for循环的最大值(99)。