Thread
:
Copy row to next empty line
View Single Post
#
8
Posted to microsoft.public.excel.programming
Dave Peterson
external usenet poster
Posts: 35,218
Copy row to next empty line
I think you're at the bottom of the worksheet.
I'd add a check to help debug:
i = i + 1
r.Copy rngTo(i)
becomes
if rngto.row = rows.count then
i = i + 1
r.Copy rngTo(i)
else
msgbox "You're out of space!
end if
It could be because you don't have anything below A1 in Sheets(6)--or you have
everything filled in on that column A of that sheet.
wrote:
Hi,
Very new to this so would be grateful for any help.
I'm trying to copy rows from one workbook to another when they meet a
certain criteria. But I do not want to overwrite previously copied
lines. I want to add new rows, that meet the criteria, to the end of
the older copied data.
Dont know whether its relevent but to make sure that lines that are
already on sheet 6 aren't duplicated, I have a lookup function in col
23 of sheet 1 that brings back the unique identifier if it is already
on sheet 6.
I know this is very convaluted!
Sub UnmatchedPOs()
Set rng = Sheets(1).Range("A:V").Rows
Set rngTo = Sheets(6).Range("A1").End(xlDown)
For Each r In rng
If r.Cells(3).Value = "NO" Then
If r.Cells(9).Value = DateValue("April, 01, 2007") Then
If r.Cells(9).Value < DateValue("April 01, 2008") Then
If Not r.Cells(6).Value = r.Cells(23).Value Then
i = i + 1
r.Copy rngTo(i)
End If
End If
End If
End If
Next
End Sub
When I run this I get:
1004 - Application defined or object defined error
Many Thanks,
Jig
--
Dave Peterson
Reply With Quote
Dave Peterson
View Public Profile
Find all posts by Dave Peterson