Hi there
I'm using the code below to insert a blank row whenever there is a change in name in column F, but I'd like to fill the row with a specific colour for each change in name. Can anyone help me with this? It will be a different colour for each name, so what would be the best way to do this? (the colour only needs to fill the inserted blank row, nothing else)
Option Compare Text
Sub addRows()
Dim Rw As Long
Dim LastRw As Long
LastRw = ActiveSheet.UsedRange.Rows.Count
' loop through column F
For Rw = LastRw To 2 Step -1
'ignore empty cells
If Not IsEmpty(Cells(Rw - 1, 6)) Then
'if the cells don't match add a row
If Cells(Rw, 6).Value <> Cells(Rw - 1, 6).Value Then
Cells(Rw, 6).EntireRow.Insert Shift:=xlDown
End If
End If
Next Rw
End Sub
Bookmarks