【发布时间】:2017-12-27 02:16:28
【问题描述】:
扩展问题来自- Excel: How to copy a row if it contains certain text to another worksheet (VBA)
我希望修改下面的代码,以便它能够从表 2 复制到表 4,粘贴相邻 (L:U)?看图片。
Option Explicit
Sub Test()
Dim Cell As Range
With Sheets(1)
' loop column H untill last cell with value (not entire column)
For Each Cell In .Range("H1:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If Cell.Value = "FAIL" Then
' Copy>>Paste in 1-line (no need to use Select)
.Rows(Cell.Row).Copy Destination:=Sheets(4).Rows(Cell.Row)
End If
Next Cell
End With
End Sub
评论回复图片pic3
【问题讨论】:
标签: vba excel copy-paste