如果满足条件,我会尝试复制不同的范围。例如,如果在列X中单词" TFX"找到,然后复制整行和所有行后如果有信息(只有第一行有单词" TFX")。
这是我到目前为止的代码。我试图只复制3行但我发现在某些情况下超过3行。
Sub CopySAbiertopropose()
Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet
Dim wb As Workbook
Call NewWorkBook
Workbooks("Proposenet General").Sheets(1).Rows(1).Copy
Workbooks("Proposenet IX-OM-VA").Sheets(1).Rows(1).Paste
' Change worksheet designations as needed
Set Source = Workbooks("Proposenet General").Sheets(1)
Set Target = Workbooks("Proposenet IX-OM-VA").Sheets(1)
j = 2 ' Start copying to row 2 in target sheet
For Each c In Source.Range("N1:N50000") ' Do 50000 rows
If c = "TFX" Then
Source.Range("A" & c.Row - 1 & ":V" & c.Row - 1).Copy Target.Range("A" & j)
Source.Range("A" & c.Row & ":V" & c.Row).Copy Target.Range("A" & j)
Source.Range("A" & c.Row + 1 & ":V" & c.Row + 1).Copy Target.Range("A" & j)
j = j + 1
End If
Next c
End Sub
如果您需要一些额外信息,请告诉我。
问候。