Добавить пустые строки
Совет
Закомментированная строка Cells(iRow + 1, cCol).Interior.ColorIndex = 3
добавляет красный цвет в первую ячейку добавленной строки, что очень помогает при попытке выяснить такой код.
Половина версии
Sub AddBlankRows()
Const cCol As Variant = "A"
Const cFirstR As Long = 1
Dim LastR As Long
Dim iRow As Long
LastR = Cells(Rows.Count, cCol).End(xlUp).Row
iRow = cFirstR
Do
If Cells(iRow, cCol) <> "" And Cells(iRow + 1, cCol) <> "" Then
If Cells(iRow, cCol) <> Cells(iRow + 1, cCol) Then
Cells(iRow + 1, cCol).EntireRow.Insert xlShiftDown
'Cells(iRow + 1, cCol).Interior.ColorIndex = 3
LastR = LastR + 1
End If
End If
iRow = iRow + 1
Loop Until iRow > LastR
End Sub
Полная версия
Sub AddBlankRows2()
Const cCol As Variant = "A,C"
Const cFirstR As Long = 1
Dim vnt As Variant
Dim LastR As Long
Dim iRow As Long
Dim i As Long
vnt = Split(cCol, ",")
For i = 0 To UBound(vnt)
LastR = Cells(Rows.Count, vnt(i)).End(xlUp).Row
iRow = cFirstR
Do
If Cells(iRow, vnt(i)) <> "" And Cells(iRow + 1, vnt(i)) <> "" Then
If Cells(iRow, vnt(i)) <> Cells(iRow + 1, vnt(i)) Then
Cells(iRow + 1, vnt(i)).EntireRow.Insert xlShiftDown
'Cells(iRow + 1, vnt(i)).Interior.ColorIndex = i + 3
LastR = LastR + 1
End If
End If
iRow = iRow + 1
Loop Until iRow > LastR
Next
End Sub