Bottom Line: In this post we look at 3 ways to copy down values in blank cells in a column. The techniques include using a formula, Power Query, and a VBA macro.
Skill Level: Intermediate
Watch the Tutorial
Download the Excel Files
You can download both the BEGIN and FINAL files if you want to follow along and practice.
Fill Down Techniques BEGIN.xlsx (323.3 KB)
Fill Down Techniques FINAL.xlsm (465.5 KB)
Filling Down Blank Cells
Excel makes it easy to fill down, or copy down, a value into the cells below. You can simply double-click or drag down the fill handle for the cell that you want copied, to populate the cells below it with the same value.
But is there an easy way to replicate that process hundreds of times for reports that have large amounts of data?
In this post we'll look at three ways to automate this process with: a simple formula, Power Query, and a VBA macro.
1. Filling Down Using a Formula
The first way to solve this problem is by using a very simple formula in all of the blank cells that references the cell above. Here are the steps.
Step 1: Select the Blank Cells
In order to select the blank cells in a column and fill them with a formula, we start by selecting all of the cells (including the populated cells). There are many ways to do this, including holding the Shift key down while you navigate to the bottom of your column, or if your data is in an Excel Table, using the keyboard shortcut Ctrl+Space.
Checkout my posts on 7 Keyboard Shortcuts for Selecting Cells and Ranges in Excel and 5 Keyboard Shortcuts for Rows and Columns in Excel to learn more.
With all of those cells selected, we can pare down our selection to include only the blank cells. This is done by using the Go To Special window from the Find & Select menu on the Home tab of the ribbon.
An alternative is to open the Go To window using F5 or Ctrl+G. Then press the Special button for the Go To Special window.
Once the Go To Special window is open, you can choose the option that says Blanks. This will select only the blank cells from the current selection.
When you hit OK, you'll notice that the cells that have values in them are no longer selected.
Step 2: Write the Formula
From here you can start typing the formula, which is very simple. Type the equals sign (=) and then reference the cell above (in the case of our example, B2). That's all you need for the formula!
Step 3: Ctrl+Enter the Formula
After writing the formula, don't just hit Enter. Instead, use Ctrl+Enter to fill all of the selected cells with the same formula. Hold the Ctrl key, then hit Enter.
Because your formula reference is relative (B2), not absolute ($B$2), each cell will simply copy the value for the cell directly above it.
Step 4: Copy & Paste Values
It is a good idea to now copy the entire data column and then paste over it using the Paste Values option so that the data is hard coded. Then, if you do any sorting, the data will not change. You can find the Paste Values option on the Home tab in the Paste drop-down menu:
There are other ways to paste values, including the right-click menu or using keyboard shortcuts. These posts explain those options:
2. Filling Down Using Power Query
For this option, your data should be in Excel Table format. From anywhere inside the table, you can select the Data or Power Query tab, and then select From Table/Range. You can also create a query that connects to a different data source like a database or the web.
This opens up the Power Query Editor. In Power Query, the blank cells are labeled as null in each cell.
To fill down, just right-click on the column header and select Fill and then Down.
Power Query will fill down each section of blank cells in the column with the value from the cell above it.
When you click on Close & Load, a new sheet will be added to the workbook with these changes.
This process of filling down can be done for multiple columns simultaneously by first selecting multiple columns with Ctrl or Shift, then performing the Fill > Down operation.
If Power Query is somewhat new to you, I invite you to check out this post: Power Query Overview: An Introduction to Excel’s Most Powerful Data Tool.
Free Webinar on Power Query, VBA, & More
I also have a free webinar running right now that covers an introduction to Power Query and the other Excel tools like Power Pivot, Power BI, Macros & VBA, pivot tables, and more.
3. Filling Down Using a Macro
To fill down using a macro, start by opening the VB Editor. You can do this by going to the Developer tab and clicking on the Visual Basic button or by using the keyboard shortcut Alt+F11. Insert a new code module, and then write your macro.
This macro loops through all of the cells in the selected range and performs the FillDown method if the cell is blank. The FillDown method copies the value from the cell above.
If this is a macro that you could use frequently, you might want to consider adding this macro to your personal Macro Workbook and creating a customized button for it. That's what I've done and it looks like this on my Ribbon.
For instruction on how to create a Personal Macro Workbook and custom Ribbon buttons, check out this tutorial: How to Create a Personal Macro Workbook (Video Series).
Pros and Cons
So which of these three methods are right for you? Consider these things:
- The formula method is simple and easy to implement. It can be done without any knowledge of Power Query or VBA. However, it's not as quick as a one-click button solution.
- Power Query requires source data that outputs into a separate worksheet, so it's more of a process than simply filling down blank cells. If you are already data cleansing on a regular basis for other things, adding this to your existing process might make more sense.
- Once the initial macro is set up, VBA is a quick solution that's easy to use—just click a button. However, there is a big disadvantage of this method. You aren't able to undo your action once that button has been pushed, so you would have to be sure to save a backup copy beforehand if that is a concern for you.
There are three different methods for a very common Excel task. Did I miss any? Please leave a comment below if you have another way to go about it, or have any questions. Thanks! 🙂