Please, I need to insert a row in a sheet if the value in column F changes, like attached files.
The best code that I could adapt was found here:
http://www.mrexcel.com/forum/excel-q...lumns-c-d.html
Then I changed it to:
But it doesn't work.![]()
Sub InsertRows() Dim myLastRow As Long Dim myRow As Long Application.ScreenUpdating = False ' Find last row with data in column A myLastRow = Cells(Rows.Count, "A").End(xlUp).row ' Loop through all rows in column A, starting at row 1 For myRow = 1 To myLastRow ' Check to see if value in column A is 0 If Len(Cells(myRow, "F")) = 1 And Cells(myRow, "F") = 2 Then ' Insert blank rows from A to F Range(Cells(myRow, "A"), Cells(myRow, "F")).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove End If Next myRow Application.ScreenUpdating = True End Sub
Bookmarks