我有两个循环工作,因此,如果列I中的任何单元格= celll.Value,请继续执行第二个循环,如果列J中的任何单元格类似于“活动编号”,则打印单元格偏移量单元格值。但是,循环继续进行并且不会停止,继续重复相同的值。
For Each celll In SubTaskWs.Range("I1:I" & Lastrow)
If celll.value = deliveryWs.Range("N9") Then
For Each cel In SubTaskWs.Range("J1:J" & Lastrow)
If cel.value Like activityNumber Then
'Insert row at the last position of Activity table
deliveryWs.Range("A" + CStr(delivActivEnd + (i))).EntireRow.Insert
' Copy formatting from line above
Call copyFormattingAbove(deliveryWs, "A" & CStr(delivActivEnd + i))
'copy cell offset hit to newly inserted row
deliveryWs.Range("C" & CStr(delivActivEnd) + (i - 1)).value = cel.Offset(, -7)
deliveryWs.Range("H" & CStr(delivActivEnd) + (i - 1)).value = cel.Offset(, -6)
deliveryWs.Range("I" & CStr(delivActivEnd) + (i - 1)).value = cel.Offset(, -5)
deliveryWs.Range("P" & CStr(delivActivEnd) + (i - 1)).value = cel.Offset(, 1)
' Number Deliverable
deliveryNum = deliveryWs.Range("B" & CStr(delivActivEnd - 1)) + (0.1 + (i / 10))
deliveryWs.Range("B" & CStr(delivActivEnd) + i) = deliveryNum
' Update sum of workload for activity
Call updateActivityWorkload(deliveryWs, activityNumber, delivActivStart, (delivActivEnd + i))
' Create new line for deliverable on Delivery and Validation for Invoicing table
Call updateInvoicingTable(deliveryWs, (delivActivEnd + i), (delivActivEnd + i) - deliverablesStart)
i = i + 1
End If
Next cel
End If
Next celll
我希望它只在列中循环一次,而不要重复值。