在特定列的空白单元格中插入公式

时间:2016-06-24 12:47:05

标签: excel excel-vba formula vba

我想在A列的任何空白单元格中插入公式,公式为

=vlookup([cell ref],worksheet,A:Z,2,0) 

其中单元格ref是列C中的相邻单元格。我无法覆盖整个列,因为公式将返回的某些值不再可用。由于C列每周都会扩展,因此无法设置单元格数。

1 个答案:

答案 0 :(得分:0)

使用以下数据:

enter image description here

我们希望使用以下公式填充 A 列中的空单元格

=B1+C1

这个宏:

Sub FillStuff()
    Dim r As Range
    Set r = Range("A:A").Cells.SpecialCells(xlCellTypeBlanks)
    r.Formula = "=C1+B1"
End Sub

将产生:

enter image description here

相关问题