I am getting a weird output from this macro. The macro should fill the blank cells with the color above creating a block of colors. The result is not what I expected even though
The varying colors is due to the nature of ColorIndex, which as MSDN notes represents the index of a color in a palette. Colors from different palettes will have the same index number, so use Color instead of ColorIndex.
Change ColorIndex to Color within the innermost If...End IF.
Sub Crayon()
Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1")
Dim MyCell As Range
For Each MyCell In ws.Range("A2:A" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row)
If MyCell.Interior.ColorIndex = xlNone Then
If MyCell.Offset(-1).Interior.ColorIndex <> xlNone Then
MyCell.Interior.Color = MyCell.Offset(-1).Interior.Color
End If
End If
Next MyCell
End Sub