I have this subroutine that adds an additional row after any row that contains certain keywords.
Everything is working as intended except for the second If statement (red text)
error message "Next without For" keeps poping up, see code below
Sample test file is also attached below. Please help !
Everything is working as intended except for the second If statement (red text)
error message "Next without For" keeps poping up, see code below
Sample test file is also attached below. Please help !
VBA Code:
Sub Flowline()
rng2 As Range 'this is defined as Public at the beginning of the macro
lr4 As Long 'this is defined as Public at the beginning of the macro
Set rng2 = Range("A1").CurrentRegion
lr4 = rng2.Cells(Rows.Count, "K").End(3).Row
For i = lr4 To 2 Step -1
If rng2.Cells(i, 11) Like "*4'dia**Invert*" Then
rng2.Cells(i, 11).Offset(1).EntireRow.Insert
rng2.Cells(i, 3).Offset(1).Resize(1, 9).Value = _
Array("1", "F14050J", "Yes", "", "", "185", "Production", "500", "FLOWLINE,4' Diameter")
rng2.Cells(i, 1).Offset(1).Resize(1, 2).Value = rng2.Cells(i, 1).Resize(1, 2).Value
[COLOR=rgb(184, 49, 47)] If rng2.Cells(i, 11) Like "*4'dia**Invert*" And _
rng2.Cells(i, 14) Like "*Toho Water*" Then
rng2.Cells(i, 11).Offset(1).EntireRow.Insert
rng2.Cells(i, 3).Offset(1).Resize(1, 9).Value = _
Array("1", "F14050XJ", "Yes", "", "", "185", "Production", "500", "FLOWLINE,4' Diameter")
rng2.Cells(i, 1).Offset(1).Resize(1, 2).Value = rng2.Cells(i, 1).Resize(1, 2).Value [/COLOR]
ElseIf rng2.Cells(i, 11) Like "*5'dia**Invert*" Then
rng2.Cells(i, 11).Offset(1).EntireRow.Insert
rng2.Cells(i, 3).Offset(1).Resize(1, 9).Value = _
Array("1", "F15050J", "Yes", "", "", "150", "Production", "500", "FLOWLINE,5' Diameter")
rng2.Cells(i, 1).Offset(1).Resize(1, 2).Value = rng2.Cells(i, 1).Resize(1, 2).Value 'This fills cols A&B with variable values
End If
Next i
End Sub