Я пытаюсь скопировать три конкретные строки из ActiveSheet
и хочу вставить / вставить эти три диапазона на основе ColorIndex
.
Dim last1Row As Long, J As Long
Set ws = ThisWorkbook.Sheets("sheet1") 'set you data sheet here
last1Row = ws.Cells(Rows.Count, "M").End(xlUp).Row 'get the last row in column A
For J = last1Row To 7 Step -1 'loop from last row to row 2
If ws.Range("M" & J).Interior.ColorIndex = 37 Then
ws.Range("M" & J + 2).EntireRow.Insert
ws.Rows("4:4").Copy
ws.Range("M" & J + 2).EntireRow.Insert
ws.Rows("3:3").Copy
ws.Range("M" & J + 2).EntireRow.Insert
ws.Rows("1:1").Copy
ws.Range("M" & J + 2).EntireRow.Insert
ws.Rows("5:5").Copy
End If
Next J