如果相邻单元格不为空,则从上面的单元格自动填充+匹配

时间:2017-07-10 07:24:54

标签: excel vba autofill

我对VBA并不熟悉,所以请耐心等待。

我的问题与此链接有关:Double-click autofill - dynamic based on adjacent cell

enter image description here

但是,属性位于另一列(例如E列)。我试过调整代码,但无济于事。

1 个答案:

答案 0 :(得分:0)

这对你有用吗?

Sub FillBlanks()
Dim lr As Long
lr = Cells(Rows.Count, "E").End(xlUp).Row   'Assuming Attributes are in Column E
On Error Resume Next
'Assuming you want to fill blanks in column A
With Range("A1:A" & lr).SpecialCells(xlCellTypeBlanks)
    .Formula = "=R[-1]C"
    .Value = .Value
End With
End Sub