Spreadsheet Practice

How to return the category from a merged cell above in Excel

Formula (Excel and Google Sheets)

=IF(A2="",C1,A2)

Repeat the last category until a new one appears: =IF(A2="",C1,A2), filled down.

Result on the example
one result per row in C2, filled down to C10
Works in
Every current version
Google Sheets
Same formula

See it work

The formula is already in C2, filled down to C10. Change any input and the result updates, or edit the formula to experiment.

How it works

When a merged cell is unmerged or read by a formula, only its top cell holds the value; the rest are empty. The formula takes the category from column A when there is one and otherwise repeats the result from the row above (C1 for row 2), so each item carries its group's category down.

=IF(A2="",C1,A2)

Result"Fruit"

  1. A2"Fruit"

    The value in A2.

  2. A2=""FALSE

    The = operator tests whether the two sides are equal.

  3. C1"Category (filled)"not used

    The value in C1.

  4. IF(A2="",C1,A2)"Fruit"

    IF: Returns one value if a test is true, another if false.

    • logical_testA2=""FALSE
    • value_if_trueC1"Category (filled)"not used
    • value_if_falseA2"Fruit"

In Google Sheets

The same formula works in Google Sheets: =IF(A2="",C1,A2). We ran it in Google Sheets mode on the same data and it returns the same results.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=XLOOKUP(TRUE,A$2:A2<>"",A$2:A2,,0,-1)Fruit, Fruit, Fruit…Looks back up column A for the nearest filled cell, without referring to the result column. Useful inside other formulas.

Common mistakes

  • Sorting or filtering merged ranges fails. Unmerge the cells and fill the category into every row first.
  • If the first data row has no category, the formula repeats the header. Make sure each group starts with its name.

Try it yourself

Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.

Return the category from a merged cell above

The categories were merged cells, so only the first row of each group has one. In C2, return the category that applies to the row, then fill down to C10.

Questions

How do I fill the blanks with the value above without a formula?

Select the column, use Go To Special > Blanks, type = and the cell above, and press Ctrl+Enter. Then paste values.

How do I sum by category afterwards?

Use the filled column in SUMIF: =SUMIF(C2:C10,"Bakery",amounts).

Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.