Exclude rows with result 1

R

Robert

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
 
J

Joel

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
 

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

Similar Threads


Top