How to Fill Blank Cells With the Value Above in Excel VBA

When working with large datasets in Excel, you might often encounter situations where you have blank cells that need to be filled with the value from the cell above. This can be a tedious task if done manually, especially with a massive amount of data. However, by using Excel’s Visual Basic for Applications (VBA), this task can be executed quickly and efficiently. In this tutorial, we will cover the steps to fill blank cells with the value above using VBA.

Steps to Create the VBA Macro

Follow these steps to create a VBA macro that will fill in blank cells in your Excel spreadsheet with the value from the cell directly above:

  1. Press ALT + F11 to open the VBA editor.
  2. In the VBA editor, go to Insert > Module to add a new module.
  3. In the module window, copy and paste the following VBA code:
  1. Close the VBA editor and return to your Excel worksheet.
  2. Select the range of cells where you want to fill in blank cells with the value above.
  3. Press ALT + F8, select the ‘FillBlanksWithAbove’ macro and run it.

The macro will iterate through each cell in your selection and fill in the blanks with the value from the cell above. It’s important to note that it will only work if there’s a value in the cell above and the selected range is contiguous.

Customizing Your Macro

For more advanced users, you may want to customize the macro according to your specific needs. You could adjust the range to a predefined range within your macro, or modify it to include additional checks and balances, depending on your dataset’s nature.

Remember to test your macro in a copy of your data before running it on your main dataset to prevent any unintended changes.


In this tutorial, we’ve covered the steps to automate the process of filling blank cells with the value above using Excel VBA. By using VBA, you can greatly enhance your productivity and efficiency when managing large datasets. With just a small snippet of code, monotonous tasks can be a thing of the past, making Excel an even more powerful tool in your workflow.

Tomasz Decker is an Excel specialist, skilled in data analysis and financial modeling.

Posted in vba