Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Exclude rows with result 1

Hi All,

The below statement should only copy the rows that have a "0" in
column A but for some reason all values (0 and 1) are copied.
Can someone tell me how to adjust this statement so that only the rows
with "0" are subtracted?

Thanks a lot

Regards,
Robert

'Exclude all Swaps
Dim iLastRow As Long, iNextRow As Long
Dim i As Long
With Worksheets("Positions")
iLastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i, "A").Value = 0 Then
iNextRow = iNextRow + 1
.Cells(i, "B").Resize(, 21).Copy _
Worksheets("Cut-Out").Cells(iNextRow, "A")
End If
Next i

End With
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Exclude rows with result 1

you are missing the period in front of cells on this line
from
If Cells(i, "A").Value = 0 Then
to
If .Cells(i, "A").Value = 0 Then


"Robert" wrote:

Hi All,

The below statement should only copy the rows that have a "0" in
column A but for some reason all values (0 and 1) are copied.
Can someone tell me how to adjust this statement so that only the rows
with "0" are subtracted?

Thanks a lot

Regards,
Robert

'Exclude all Swaps
Dim iLastRow As Long, iNextRow As Long
Dim i As Long
With Worksheets("Positions")
iLastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i, "A").Value = 0 Then
iNextRow = iNextRow + 1
.Cells(i, "B").Resize(, 21).Copy _
Worksheets("Cut-Out").Cells(iNextRow, "A")
End If
Next i

End With

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
Pivot Tables - Exclude Rows With Zero Balances bobs Excel Discussion (Misc queries) 2 January 10th 08 01:53 PM
pivot chart exclude rows sugargenius Excel Programming 0 February 22nd 07 12:47 PM
Is there a way to exclude hidden rows/columns when printing a doc Jeanette Abbott-Bell Setting up and Configuration of Excel 3 April 5th 06 10:39 PM
Copy rows, but exclude blank rows Mary[_9_] Excel Programming 1 November 1st 05 07:21 AM
Averages: Exclude Rows with 0 Values Goody Excel Worksheet Functions 5 April 2nd 05 04:35 AM


All times are GMT +1. The time now is 08:51 PM.

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

About Us

"It's about Microsoft Excel"