A spreadsheet grid with one selected cell and the Excel-User mark

Excel VBA FillDown: How to Fill Blank Cells in a Column

Excel-User editorial team
Written by admin

17/09/2026

By Excel-User Editorial TeamLast verified: Method behaviour and constants checked against Microsoft’s VBA object model reference. How we verify.

Quick answer

VBA FillDown does not skip blanks. Range("A1:A10").FillDown copies the top cell over everything below it, filled or not. To fill only the gaps, select them first with SpecialCells(xlCellTypeBlanks) and write a relative R1C1 formula into them: .FormulaR1C1 = "=R[-1]C". Then convert only those cells back to values, looping over their areas — not the whole column, which would flatten formulas that were already there.

Two different jobs share one name here, and mixing them up is what sends people looking for this page. FillDown is a copy operation. Filling the blanks in a column is a repair operation. The first will happily destroy your data while doing exactly what it was asked.

What Range.FillDown actually does

Microsoft’s own description is blunt: the method “fills down from the top cell or cells in the specified range to the bottom of the range”, and “the contents and formatting of the cell or cells in the top row of a range are copied into the rest of the rows in the range”.

Worksheets("Sheet1").Range("A1:A10").FillDown

A1 wins. A2 through A10 become copies of it — values, formulas and formatting alike. Nothing checks whether A5 already held something worth keeping.

It works on blocks too. Given Range("A1:D10").FillDown, the whole of row 1 is copied down through row 10. And because Selection is just a Range, Selection.FillDown is the same method aimed at whatever the user happens to have highlighted — which is why it shows up in recorded macros and why it is worth treating carefully in code someone else will run.

Used deliberately, this is useful: it is the VBA equivalent of pressing Ctrl+D, and it is the right call when you genuinely want one formula propagated down a column. It is simply not a blanks tool.

The macro you actually want

To fill only the empty cells, narrow the range to the empty cells before you write anything.

Sub FillBlanksDown()
    Dim rng As Range, filled As Range, a As Range

    ' Start at the first row of DATA, never at row 1.
    Set rng = ActiveSheet.Range("A2:A500")

    On Error Resume Next
    Set filled = rng.SpecialCells(xlCellTypeBlanks)
    On Error GoTo 0

    If filled Is Nothing Then Exit Sub

    filled.FormulaR1C1 = "=R[-1]C"

    ' Convert only the cells we just wrote, one area at a time.
    For Each a In filled.Areas
        a.Value = a.Value
    Next a
End Sub

SpecialCells(xlCellTypeBlanks) returns just the empty cells — the same selection you would get from Go To Special in the interface. Writing =R[-1]C into them puts a formula in each one pointing at the cell directly above. Keeping that subset in filled is what makes the last step safe: the loop replaces the formulas with their results only in the cells the macro wrote.

Converting the whole column instead, with rng.Value = rng.Value, is the version you will find all over the web, and it is a data-loss bug. That line flattens every cell in A2:A500, so any formula that was already sitting in a non-empty cell is silently replaced by whatever it happened to return — with no undo, because macro edits clear the undo stack. The loop runs area by area for a second reason: SpecialCells hands back a multi-area range, and .Value = .Value on one of those copies the first area over all the others.

Never start the range at row 1. =R[-1]C means “one row up”, so in A1 it points off the top of the sheet and returns #REF!. Starting at A2 is safe for the formula, but if A2 itself is blank the macro pulls your header down into the data — begin at the first row that genuinely holds data.

The cascade takes care of runs of blanks. The first gap cell reads the last real value above it; the second gap cell reads the first, which now holds that value; and so on down the run.

Why R1C1, and not “=A1”

This is the detail that breaks most attempts, and it is worth understanding rather than copying.

SpecialCells returns a multi-area range: a scattered collection of separate blocks, not one rectangle. When you assign an A1-style relative formula to a range, Excel translates it outwards from the top-left cell of what you assigned to. Across several disconnected areas that translation is not what you meant, and you get formulas pointing at arbitrary cells.

R1C1 notation sidesteps the problem entirely. =R[-1]C does not mean “one row above the first cell”; it means “one row above this cell, same column”, and it means that identically in every cell it lands in. The square brackets are what make it relative — R1C1 without them would be an absolute reference to cell A1.

A version you can read at a glance

If the one-liner feels too clever to maintain, the explicit loop does the same thing and is easier to modify later:

Sub FillBlanksDownLoop()
    Dim rng As Range, c As Range

    On Error Resume Next
    Set rng = ActiveSheet.Range("A2:A500").SpecialCells(xlCellTypeBlanks)
    On Error GoTo 0

    If rng Is Nothing Then
        MsgBox "No blank cells in that range."
        Exit Sub
    End If

    Application.ScreenUpdating = False
    For Each c In rng
        c.Value = c.Offset(-1, 0).Value
    Next c
    Application.ScreenUpdating = True
End Sub

This writes values directly, so there is no conversion step. For Each walks the areas in order and the cells within each area top to bottom, which is exactly the order the cascade needs. On a large column, ScreenUpdating = False is the difference between instant and visibly slow.

Handle the no-blanks case

SpecialCells does not return an empty range when it finds nothing — it raises run-time error 1004. On a column with no gaps, an unguarded macro simply stops with a dialog in the user’s face.

That is what On Error Resume Next is doing in both examples above. In the loop version it is paired with an If rng Is Nothing check, which is the more honest pattern: catch the error, then test whether you actually got a range, and only afterwards switch error handling back on with On Error GoTo 0.

One more practical note: xlCellTypeBlanks is a built-in constant with the value 4. Inside Excel you can use the name. If you are driving Excel from another application through late binding, the names are not available and you pass the number instead.

The variants side by side

What you wantCodeOverwrites filled cells?
Copy the top cell down a columnRange("A1:A10").FillDownYes
Copy the top row of a block downRange("A1:D10").FillDownYes
Same, on the user’s selectionSelection.FillDownYes
Fill only the gaps.SpecialCells(4).FormulaR1C1 = "=R[-1]C"No
Replace formulas with results, safelyFor Each a In filled.Areas: a.Value = a.Value: Next aNo, only the cells it filled
Replace formulas with results, whole columnrng.Value = rng.ValueYes — destroys existing formulas
xlCellTypeBlanks is 4. Only the fourth row is blank-aware.

Where Fill Down lives outside VBA

If you arrived here looking for the command rather than the method: Fill Down is on the Home tab, in the Editing group, under Fill → Down. The shortcut is Ctrl+D, which Microsoft documents as copying “the contents and format of the topmost cell of a selected range into the cells below” — the same overwriting behaviour as the VBA method, because it is the same command.

For a one-off repair you do not need a macro at all. Go To Special selects the blanks by hand in about eight seconds, and the step-by-step route for filling blank cells with the value above covers it, along with the Power Query version for data you reimport every week. Reach for the macro when you have many columns, many sheets or many files — the point at which doing it by hand stops being eight seconds.

If this is your first macro on a real workbook, the same cautions apply as to any VBA that writes in bulk: run it on a copy, and remember that macro edits cannot be undone with Ctrl+Z. The notes on that in putting borders around all used cells are worth a look, and deleting all pictures or charts on a worksheet uses the same SpecialCells pattern for a different object type.

Frequently asked questions

What does Selection.FillDown do in VBA?

It copies the contents and formatting of the top row of the selection into every row below it, within that selection. It is the VBA equivalent of pressing Ctrl+D. It does not check whether the lower cells already hold data, so on a column with scattered values it overwrites all of them.

How do I fill only the blank cells with VBA?

Narrow the range to the blanks first, then write a relative R1C1 formula into them: Range("A2:A500").SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C". Hold that subset in a variable and turn the formulas into values in those cells only, looping over its .Areas. Running rng.Value = rng.Value over the whole column instead would flatten any formulas that were already in the non-empty cells. Never start the range at row 1 either: =R[-1]C returns #REF! there. FillDown on its own cannot do any of this.

Why does SpecialCells throw run-time error 1004?

Because no cells matched. SpecialCells raises error 1004 rather than returning an empty range when there are no blanks in the range you gave it. Wrap the call in On Error Resume Next, then test If rng Is Nothing before using the result, and restore handling with On Error GoTo 0.

What is the value of xlCellTypeBlanks?

4. It is a member of the XlCellType enumeration in the Excel object model. Inside Excel VBA you can write the constant name directly; when you automate Excel from another application through late binding the names are not available, so you pass 4 instead.

Where is Fill Down in Excel?

On the Home tab, in the Editing group, under Fill, then Down. The keyboard shortcut is Ctrl+D. It copies the topmost cell of the selected range into the cells below it, so use Go To Special first if you only want to fill the empty ones.

Sources

  1. Range.FillDown method (Excel) — Microsoft Learn. Accessed September 17, 2026.
  2. Range.SpecialCells method (Excel) — Microsoft Learn. Accessed September 17, 2026.
  3. XlCellType enumeration (Excel) — Microsoft Learn. Accessed September 17, 2026.
  4. Keyboard shortcuts in Excel — Microsoft Support. Accessed September 17, 2026.

Excel-User Editorial Team

Excel-User has published Excel guidance since 2007. We check method behaviour, constants and shortcuts against Microsoft’s own object model reference, and say plainly which versions a feature needs. About us · How we evaluate

Excel-User editorial team

Excel-User is an independent guide to Excel and financial-modeling certifications and courses. Every price, exam objective and policy here is checked against the issuer's own pages, labelled as verified or as a provider claim, and dated. Where two official sources disagree, we say so instead of picking one. How we verify · About Excel-User

2 thoughts on “Excel VBA FillDown: How to Fill Blank Cells in a Column”

Leave a Comment