Copy lines with specific value

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
 
D

Dan R.

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
 
J

johnboy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top