Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy lines with specific value
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy lines with specific value
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 -- Dan |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy lines with specific value
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 -- JB "Robert" wrote: 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy lines with specific value
Thanks a lot Dan!!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to modify specific lines in a .ini file? | Excel Discussion (Misc queries) | |||
printing specific lines | Excel Discussion (Misc queries) | |||
How do I get page down to move a specific # of lines in Excel? | Excel Worksheet Functions | |||
VBA, copy lines with specific value | Excel Programming | |||
Print only lines that have a value in a specific colum | Setting up and Configuration of Excel |