I have a column like the following:
1 red
2 blue
3 red
4
5 blue
6
7
8 white
The blanks refer to the record above it. So #4 would be associated with red and 6 and 7 would be blue.
Is there an easy way to fill in the blanks for entire column?
A1:A8
. F5
to show the Goto dialog. That will select a noncontiguous range of blank cells.
=A3
and press control+enter. A1:A8
, and Edit - Copy. Note that the =A3
refers to the cell above the first blank cell.
If you want to do it with a macro, you could loop through the cells and fill in the empty ones.
Public Sub FillBlanks()
Dim rColumn As Range
Dim rCell As Range
If TypeName(Selection) = "Range" Then
For Each rColumn In Selection.Columns
For Each rCell In rColumn.Cells
If rCell.Row > rColumn.Cells(1).Row Then
If IsEmpty(rCell.Value) Then
rCell.Value = rCell.Offset(-1).Value
End If
End If
Next rCell
Next rColumn
End If
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With