Fill blank cells (Variation)

前端 未结 2 1969
甜味超标
甜味超标 2020-12-12 07:28

I have an issue with filling blank cells of a column.

I have 3 Column headings in A, B, C.

Under that I have variable amounts of rows, but column A and B wil

2条回答
  •  佛祖请我去吃肉
    2020-12-12 08:28

    Don't use all of Column C -- first determine how far the data in Column A extends and then grab that many cells in column C:

    Sub FillCellsFromAbove()
        Dim R As Range, n As Long
    
        n = Range("A:A").Rows.Count
        n = Cells(n, "A").End(xlUp).Row
        Set R = Range(Cells(1, 3), Cells(n, 3))
    
        Application.ScreenUpdating = False
        On Error Resume Next
        With R
            ' For blank cells, set them to equal the cell above
            .SpecialCells(xlCellTypeBlanks).Formula = "=R[-1]C"
            'Convert the formula to a value
            .Value = .Value
        End With
        Err.Clear
        Application.ScreenUpdating = True
    End Sub
    

提交回复
热议问题