我有两个工作表 - 延迟,TP。只有当“延迟”列E具有字符串“COMPATIBLE”且列C具有字符串“通过”时,我需要从“延迟”中复制列M并将其粘贴到“TP”的列D中。VBA在不同的工作表中复制粘贴列
我有下面的代码,但它没有给出任何结果。
我不知道什么不妥:
Sub sbMoveData()
Dim lRow As Integer, i As Integer, j As Integer
'Find last roe in Sheet1
With Worksheets("Latency")
lRow = .Cells.SpecialCells(xlLastCell).Row
j = 1
For i = 1 To lRow
If UCase(.Range("E" & i)) = "COMPATIBLE" And UCase(.Range("O" & i)) = "Pass" Then
.Range("M" & i).Copy Destination:=Worksheets("TP").Range("D" & j)
j = j + 1
End If
Next
End With
末次
您的代码测试的cols E和O,但你说你想测试A和B是那是一个错字还是你真的在测试错误的cols? – DeanOC
抱歉,它的错字...它的COl E和Col O来自延迟表。将编辑OP –
在Clumn E中“当你坐下时有字符串”COMPATIBLE“,你的意思是完全匹配吗?或者也可能是”COMPATIBLE和其他东西“? –