I need my for each loop to iterate through the entire range. I have three for each loops with If-statements that checks if a condition is being met. However, the loop only iterates once even if the condition is being met or not. The sub then breaks.
Set ServiceRNG = Dataworksheet.Range("U2").End(xlDown)
Set OldServiceNamesRNG1 = ProductOderingCodeWS.Range("B7").End(xlToRight)
Set OldServiceNamesRNG2 = ProductOderingCodeWS.Range("B8").End(xlToRight)
CounterSheet1 = 2
Set Nextcellvalue = Dataworksheet.Range("U" & CounterSheet1 + 1)
Set Productorderingcode = Dataworksheet.Range("U" & CounterSheet1).Offset(0, 5)
For Each ServiceName In ServiceRNG
Nextcellvalue = Dataworksheet.Range("U" & CounterSheet1 + 1)
If ServiceName.Value = Nextcellvalue.Value Then
Productorderingcode = Dataworksheet.Range("U" & CounterSheet1).Offset(0, 5)
Productorderingcode.Copy
CounterDatabaseWS = 2
For Each OldServiceName1 In OldServiceNamesRNG1
If ServiceName.Value = OldServiceName1.Value Then
ProductOderingCodeWS.Cells(Rows.Count, CounterDatabaseWS).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Exit For
End If
CounterDatabaseWS = CounterDatabaseWS + 1
Next OldServiceName1
CounterDatabaseWS = 2
For Each OldServiceNames2 In OldServiceNamesRNG2
If ServiceName.Value = OldServiceNames2.Value Then
ProductOderingCodeWS.Cells(Rows.Count, CounterDatabaseWS).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Exit For
End If
CounterDatabaseWS = CounterDatabaseWS + 1
Next OldServiceNames2
Else
Productorderingcode = Dataworksheet.Range("U" & CounterDatabaseWS).Offset(0, 5).Value
Productorderingcode.Copy
ProductOderingCodeWS.Cells(Rows.Count, CounterDatabaseWS).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
End If
CounterSheet1 = CounterSheet1 + 1
Next ServiceName
The code runs as it should, the evaluation of conditions start at the first index of the ranges, but does not iterate through the entire range. In this case, ServiceRNG, OldeServiceNamesRNG1 and OldeServiceNamesRNG2.
F8) through the code to 'watch' the process?