Copy lines with specific value

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

Hi,

I would like to extend the below statement with a second lookup, i.e.
besides copying all lines with value RNWD I wouls also like to copy
the ones with RNTJ
Could someone tell me how to incorporate this additional command?

Many thanks!

Rgds,
Robert


Dim iLastRow As Long, iNextRow As Long
Dim i As Long
With Worksheets("Positions")
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If .Cells(i, "A").Value = "RNWD" Then
iNextRow = iNextRow + 1
.Cells(i, "A").Resize(, 21).Copy _
Worksheets("Futures").Cells(iNextRow, "A")
End If
Next i

End With
 
Robert,

Just replace this:
If .Cells(i, "A").Value = "RNWD" Then

With this:
If .Cells(i, "A").Value = "RNWD" Or .Cells(i, "A").Value = "RNTJ" Then
 
Robert,
is this what you want?

Dim iLastRow As Long, iNextRow As Long
Dim i As Long
With Worksheets("Positions")
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If .Cells(i, "A").Value = "RNWD" Or _
.Cells(i, "A").Value = "RNTJ" Then
iNextRow = iNextRow + 1
.Cells(i, "A").Resize(i, 21).Copy _
Worksheets("Futures").Cells(iNextRow, "A")
End If
Next i
End With
 
Back
Top