PDA

View Full Version : Copy row from workbook if...



realitybend
07-15-2008, 11:15 AM
I need some vba that looks at the two open workbooks. They both have numbers in them in column A. It needs to see if the number is in column A of Workbook2, and if it is, copy the row from Workbook1 and overwrite the row in Workbook2. If it isn't, then it must paste it after the last used row in Workbook2.

In workbook 1, the numbers aren't in order, but in workbook 2, they need to be.

Would anyone be willing to help me?

Thanks so much.

mdmackillop
07-15-2008, 01:36 PM
Is that not what we did here (http://www.vbaexpress.com/forum/showthread.php?t=20856)?

realitybend
07-21-2008, 10:09 AM
Basically yes, except for the ordering part. If column A has data 3, 4, 6, 7 and what I'm trying to copy has 5 in column A, it needs to insert a row and stick the data before the row with 6 in column A.

One thing I didn't mention previously; I can't use copy due to the clipboard being open and used in other macros; I have to do something like Workbooks("MyWorkbook").Worksheets("MyWorksheet").Range("D" & i).Value = Workbooks("MyWorkbook2").Worksheets("MyOtherWorksheet").Range("O7").Value