Copy data

G

Greg

Hi all I am wondering how to change this code to copy values. The trouble is
at the moment it is copying the code and causing the error code on the
cells.
sub copydata()

Dim rng As Range, cell As Range, col As Long
Dim rw As Long
col = 5
rw = 1
With Worksheets("list")
Set rng = .Range(.Cells(1, col), .Cells(Rows.Count, col).End(xlUp))
End With
For Each cell In rng
If LCase(cell.Value) = "yes" Then
cell.EntireRow.Copy Destination:=Worksheets("fortnight") _
.Cells(rw, 1)
rw = rw + 1
End If
Next

end sub

Thanks in advance

Greg
 
D

Don Guillett

try it this way.Change to suit

Sub copyifyes()
With Sheets("list")
col = 5
Set rng = .Range(.Cells(1, col), .Cells(Rows.Count, col).End(xlUp))
For Each c In rng
If LCase(c.Value) = "yes" Then
x = Sheets("Bill").Cells(Rows.Count, 1).End(xlUp).Row + 1
c.EntireRow.Copy Sheets("fortnight").Cells(x, 1)
End If
Next c
End With
End Sub
 

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

Top