I'm trying to copy different ranges if a condition is met. For example, if in column X the word "TFX" is found, then copy the entire row and all rows after if have information (only the first row have the word "TFX").
Here is the code that I have so far. I was trying to copy only 3 rows but I found that in some cases are more than 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
If you need some extra info please tell me.
Regards.