我必须从上到下滚动一个列(实际上是两个,但如果我可以管理的话),并用它上面的单元格值替换RelativeLayout
或空格。这是我到目前为止(它不起作用):
0
答案 0 :(得分:2)
如此接近:
Sub ReplaceZeros()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim lr As Long
Dim i As Long
Dim ws As Worksheet
Set ws = ActiveSheet
With ws
lr = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 2 To lr
If .Cells(i, "A").Value = 0 Then .Cells(i, "A").Value = .Cells(i - 1, "A").Value
Next i
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
注意:你已经从底部开始并且上升的循环,这没关系,但如果连续两个'0',则第二个将保持为零,加上step 7000
使循环跳过7000一次一行。
然后,如果你想要的只是上面的值,使用Cells(i-1,"A").value
将返回上面直接的单元格值。