Skip to content

Instantly share code, notes, and snippets.

@ateneva
Last active April 16, 2017 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ateneva/667fde1e25b49b9a8c7399ee1a368762 to your computer and use it in GitHub Desktop.
Save ateneva/667fde1e25b49b9a8c7399ee1a368762 to your computer and use it in GitHub Desktop.
Fill empty cells with values from the previous cells
Sub FillInEmptyCellWithPrevious()
Dim Cell As Range
Dim Region As Range
Set Region = Worksheets("Extract").Range(Cells(3, 1), Cells(ActiveSheet.UsedRange.Rows.Count, 3, 3))
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'written by Angelina Teneva, September 2016
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Each Cell In Region
If IsEmpty(Cell.Value) Then Cell.Offset(-1, 0).Select 'if cell is empty then put the value from the previous cell
Selection.Copy ActiveCell.Offset(1, 0)
Next Cell
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment