Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Copy lines with specific value

Thanks a lot Dan!!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to modify specific lines in a .ini file? Jim[_13_] Excel Discussion (Misc queries) 2 January 30th 10 08:35 PM
printing specific lines Jim Office Supply Store Owner Excel Discussion (Misc queries) 1 October 10th 08 11:42 PM
How do I get page down to move a specific # of lines in Excel? Botswana92 Excel Worksheet Functions 1 December 19th 07 02:00 PM
VBA, copy lines with specific value Robert[_30_] Excel Programming 3 February 13th 07 12:57 PM
Print only lines that have a value in a specific colum Neve Setting up and Configuration of Excel 1 August 17th 05 12:31 AM


All times are GMT +1. The time now is 07:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"