PC Review


Reply
Thread Tools Rate Thread

Copy lines with specific value

 
 
Robert
Guest
Posts: n/a
 
      11th Jul 2007
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

 
Reply With Quote
 
 
 
 
Dan R.
Guest
Posts: n/a
 
      11th Jul 2007
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

 
Reply With Quote
 
=?Utf-8?B?am9obmJveQ==?=
Guest
Posts: n/a
 
      11th Jul 2007
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
>
>

 
Reply With Quote
 
Robert
Guest
Posts: n/a
 
      11th Jul 2007
Thanks a lot Dan!!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
printing specific lines Jim Office Supply Store Owner Microsoft Excel Misc 1 10th Oct 2008 11:42 PM
VBA, copy lines with specific value Robert Microsoft Excel Programming 1 7th Feb 2008 01:29 PM
Sub to copy only result lines within formula range, omit null string lines Max Microsoft Excel Programming 4 15th Jul 2007 04:21 AM
VBA, copy lines with specific value Robert Microsoft Excel Programming 3 13th Feb 2007 12:57 PM
highlighting specific lines KAREN POST via AccessMonster.com Microsoft Access Reports 2 11th Jan 2005 05:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:24 AM.