if statement comparison & copying a row

  • Thread starter Thread starter d. williams
  • Start date Start date
D

d. williams

hello. i'm working on a macro that copies a row if the A column of that
row matches another cell's value. i'm getting an error 424, which is in
the if statement. the function is included below. i'm not sure how to
resolve this error, and something tells me the line i have which would
copy the row won't actually work, so i could use some guidance there as
well. thanks for your help.

-----
Sub test2()
Dim i As Integer, j As Integer
Dim count As Integer
count = 1
For i = 2 To 215
For j = 2 To 6693 'total no of women
If billings.Cells(i, 1).Value = women.Cells(j, 1).Value Then
women.Range("A" & j).EntireRow.Copy (mail.Rows(count))
count = count + 1
End If
Next j
Next i
End Sub
 
D.,

Are billings, women and mail worksheet names?

If so, try

Sub test2()
Dim i As Integer, j As Integer, count As Integer
count = 1
For i = 2 To 215
For j = 2 To 6693 'total no of women
If Sheets("billings").Cells(i, 1).Value = Sheets("women").Cells(j,
1).Value Then
Sheets("women").Range("A" & j).EntireRow.Copy
Destination:=Sheets("mail").Rows(count)
count = count + 1
End If
Next j
Next i
End Sub

HTH
Henry
 

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

Back
Top