Can we insert rows by criteria? Look at the example I put below it insert 3 rows. If the machine appears more than 2 or more and in collumn and in collumn (B) has a Shift # 1 so if in Collumn (A) 6,7,8 or more has the same name AND in collumn (B) has the same Shift number then insert 3 rows BUT if the name are different then insert one row beneath them OR if in collumn (A) has the same name AND Collumn (B) has different Shift numbers then only insert one row.
A Note When you see (A) & (B) those are collumns And the numbers 1 & 2 are in collumn (B)
(A) --------------------------(B)
HUNTER-2 ( LARGE 20X24 ) 1
Insert row
BUT!
If it looks like this:
(A) --------------------------(B)
HUNTER-2 ( LARGE 20X24 ) 1
HUNTER-2 ( LARGE 20X24 ) 1
insert row
insert row
insert row
OR
(A) --------------------------(B)
HUNTER-2 ( LARGE 20X24 ) 1
HUNTER-2 ( LARGE 20X24 ) 1
HUNTER-2 ( LARGE 20X24 ) 1
HUNTER-2 ( LARGE 20X24 ) 1
Insert row
insert row
insert row
OR
(A)-------------------------- (B)
HUNTER-2 ( LARGE 20X24 ) 2
HUNTER-2 ( LARGE 20X24 ) 2
Insert row
Insert row
Insert row
Now if it looks like this the code should do this:
(A) --------------------------(B)
HUNTER-2 ( LARGE 20X24 ) 1
Insert Row
HUNTER-2 ( LARGE 20X24 ) 2
HUNTER-2 ( LARGE 20X24 ) 2
Insert Row
Insert Row
Insert Row
HUNTER-4 ( LARGE 20X24 ) 1
Insert Row
OR
(A)-------------------------- (B)
HUNTER-2 ( LARGE 20X24 ) 1
HUNTER-2 ( LARGE 20X24 ) 1
Insert Row
Insert Row
Insert Row
HUNTER-3 ( LARGE 20X24 ) 2
Insert Row
HUNTER-4 ( LARGE 20X24 ) 2
HUNTER-4 ( LARGE 20X24 ) 2
Insert Row
Insert Row
Insert Row
HUNTER-2 ( LARGE 20X24 ) 1
I got this code from the forum but it only does so much.
Here is what happens when I run this code.
Sub Isertby_Criteria()
yRows = 3
lastRow = [A65536].End(xlUp).row
For i = lastRow - 1 To 2 Step -1
If Range("A" & i) = Range("A" & i + 1) Then GoTo Continue1
yCount = WorksheetFunction.CountIf(Range("A2:A" & i + 1), Range("A" & i))
If yCount = 1 Then
Range("A" & i + 1).EntireRow.Insert
End If
If yCount > 1 Then
Range("A" & i + 1, "A" & i + yRows).EntireRow.Insert
End If
Continue1:
Next i
End Sub
Thanks!

A Note When you see (A) & (B) those are collumns And the numbers 1 & 2 are in collumn (B)
(A) --------------------------(B)
HUNTER-2 ( LARGE 20X24 ) 1
Insert row
BUT!
If it looks like this:
(A) --------------------------(B)
HUNTER-2 ( LARGE 20X24 ) 1
HUNTER-2 ( LARGE 20X24 ) 1
insert row
insert row
insert row
OR
(A) --------------------------(B)
HUNTER-2 ( LARGE 20X24 ) 1
HUNTER-2 ( LARGE 20X24 ) 1
HUNTER-2 ( LARGE 20X24 ) 1
HUNTER-2 ( LARGE 20X24 ) 1
Insert row
insert row
insert row
OR
(A)-------------------------- (B)
HUNTER-2 ( LARGE 20X24 ) 2
HUNTER-2 ( LARGE 20X24 ) 2
Insert row
Insert row
Insert row
Now if it looks like this the code should do this:
(A) --------------------------(B)
HUNTER-2 ( LARGE 20X24 ) 1
Insert Row
HUNTER-2 ( LARGE 20X24 ) 2
HUNTER-2 ( LARGE 20X24 ) 2
Insert Row
Insert Row
Insert Row
HUNTER-4 ( LARGE 20X24 ) 1
Insert Row
OR
(A)-------------------------- (B)
HUNTER-2 ( LARGE 20X24 ) 1
HUNTER-2 ( LARGE 20X24 ) 1
Insert Row
Insert Row
Insert Row
HUNTER-3 ( LARGE 20X24 ) 2
Insert Row
HUNTER-4 ( LARGE 20X24 ) 2
HUNTER-4 ( LARGE 20X24 ) 2
Insert Row
Insert Row
Insert Row
HUNTER-2 ( LARGE 20X24 ) 1
I got this code from the forum but it only does so much.
Here is what happens when I run this code.
Sub Isertby_Criteria()
yRows = 3
lastRow = [A65536].End(xlUp).row
For i = lastRow - 1 To 2 Step -1
If Range("A" & i) = Range("A" & i + 1) Then GoTo Continue1
yCount = WorksheetFunction.CountIf(Range("A2:A" & i + 1), Range("A" & i))
If yCount = 1 Then
Range("A" & i + 1).EntireRow.Insert
End If
If yCount > 1 Then
Range("A" & i + 1, "A" & i + yRows).EntireRow.Insert
End If
Continue1:
Next i
End Sub
Thanks!