1
我測試了一個查找字符串「MISSING」並將數據複製/粘貼到另一個表單的小腳本。如何僅複製特定單元格
Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet
Dim sht As Worksheet
Dim LastRow As Long
Set sht = ThisWorkbook.Worksheets("Impact Analysis")
LastRow = sht.Cells(sht.Rows.count, "A").End(xlUp).Row
Set Source = ActiveWorkbook.Worksheets("Impact Analysis")
Set Target = ActiveWorkbook.Worksheets("MISSING")
j = 11 ' Start copying to row 11 in target sheet
For Each c In Source.Range("O11:O" & LastRow)
If c = "MISSING" Then
Source.Rows(c.Row).Copy Target.Rows(j)
j = j + 1
End If
Next c
然而,除了應對整個行,我想複製下面的欄目,用相同的相應行,按以下順序:J-,F,E,A和I.所以,從'影響分析'工作表中,如果列O有單詞'MISSING',我想複製J,F,E,A和I以及列O中的數據,並將所有這些粘貼到名爲'MISSING' 」。我如何修改代碼來做到這一點?