I have this code that adds 5 new rows after any row that contains Solmax or AGRU in column 11, also contain Liner in column 11, and contain Sanitary in column 15
the code is working fine when these criterias are met...the problem is it adds these 5 rows even when column 15 does not contain Sanitary.....
see file below, column 15 or column O, does not contain Sanitary
But 5 new rows got added anyways....
code below, any help is greatly appreciated
the code is working fine when these criterias are met...the problem is it adds these 5 rows even when column 15 does not contain Sanitary.....
see file below, column 15 or column O, does not contain Sanitary
But 5 new rows got added anyways....
code below, any help is greatly appreciated
VBA Code:
Sub AddRowForSanLinerItems()
Set rng2 = Range("A1").CurrentRegion, i As Long
lr8 = rng2.Cells(Rows.Count, "K").End(3).Row
For i = lr8 To 2 Step -1
If rng2.Cells(i, 11) Like "*Solmax*" Or _
rng2.Cells(i, 11) Like "*AGRU*" And _
rng2.Cells(i, 15) Like "*Sanitary*" And _
rng2.Cells(i, 11) Like "*Liner*" Then
rng2.Cells(i, 4).Offset(1).EntireRow.Insert
rng2.Cells(i, 3).Offset(1).Resize(1, 9).Value = _
Array("1", "F03957", "No", "", "", "0", "Purchased", "0", "LINER")
rng2.Cells(i, 1).Offset(1).Resize(1, 2).Value = rng2.Cells(i, 1).Resize(1, 2).Value
rng2.Cells(i, 4).Offset(2).EntireRow.Insert
rng2.Cells(i, 3).Offset(2).Resize(1, 9).Value = _
Array("1", "F03962", "No", "", "", "0", "Purchased", "0", "LINER FIELD SEAM")
rng2.Cells(i, 1).Offset(2).Resize(1, 2).Value = rng2.Cells(i, 1).Resize(1, 2).Value
rng2.Cells(i, 4).Offset(3).EntireRow.Insert
rng2.Cells(i, 3).Offset(3).Resize(1, 9).Value = _
Array("1", "F03903", "No", "", "", "0", "Purchased", "0", "LINER CONE")
rng2.Cells(i, 1).Offset(3).Resize(1, 2).Value = rng2.Cells(i, 1).Resize(1, 2).Value
rng2.Cells(i, 4).Offset(4).EntireRow.Insert
rng2.Cells(i, 3).Offset(4).Resize(1, 9).Value = _
Array("1", "F03915", "No", "", "", "0", "Purchased", "0", "LINER TURNBACK")
rng2.Cells(i, 1).Offset(4).Resize(1, 2).Value = rng2.Cells(i, 1).Resize(1, 2).Value
rng2.Cells(i, 4).Offset(5).EntireRow.Insert
rng2.Cells(i, 3).Offset(5).Resize(1, 9).Value = _
Array("1", "F03916", "No", "", "", "0", "Purchased", "0", "LINER INSTALLATION FOR BRICKWORK")
rng2.Cells(i, 1).Offset(5).Resize(1, 2).Value = rng2.Cells(i, 1).Resize(1, 2).Value
End If
Next i
End Sub