PDA

View Full Version : Solved: ANother copy/paste query



blackie42
01-21-2008, 02:58 AM
Hi,

I have 2 spreadsheets - one called UMOLD & one called OMNEW.

What I want to do is copy infos from OLD to NEW.

The infos in the 'OLD' sheet are in cells B18,C18,D18 & E18 - these are copied to the 'NEW' sheet in cells B16,C16,D16 & E16.

What I need to then do is copy the next range which is B37, C37,D37 & E37 on 'OLD' to B35,C35,D35 & E35 to 'NEW'.

I need to loop this 49 times and am having trouble figuring in out.

Any help appreciated

thanks

Jon

Bob Phillips
01-21-2008, 03:45 AM
For i = 1 To 49
Worksheets("UMOLD").Cells(i * 19 -1,"B").Resize(,4).Copy _
Worksheets("UMNEW").Cells(i * 19 - 3, "B")
Next i

blackie42
01-21-2008, 04:08 AM
Thanks for the reply but I'm not sure where this goes in the code - I got this far with it... -> BTW the 2 sheets are in diff workbooks - both sheet 1, both open at same time of course.

Application.ScreenUpdating = False
Windows("UMOLD.xls").Activate
Range("B18").Select
Selection.Copy
Windows("UMNEW.xls").Activate
Range("B16").Select
ActiveSheet.Paste
Windows("UMOLD.xls").Activate
Range("C18").Select
Application.CutCopyMode = False
Selection.Copy
Windows("UMNEW.xls").Activate
Range("C16").Select
ActiveSheet.Paste
Windows("UMOLD.xls").Activate
Range("D18").Select
Application.CutCopyMode = False
Selection.Copy
Windows("UMNEW.xls").Activate
Range("D16").Select
ActiveSheet.Paste
Windows("UMOLD.xls").Activate
Range("E18").Select
Application.CutCopyMode = False
Selection.Copy
Windows("UMNEW.xls").Activate
Range("E16").Select
ActiveSheet.Paste

I though this was where I'd need to build the repeat code & then start the loop - but got myself a bit confused....

Windows("UMOLD.xls").Activate
Application.CutCopyMode = False
ActiveCell.Offset(21, -3).Select

Bob Phillips
01-21-2008, 05:17 AM
Your code cann be simplified to



Application.ScreenUpdating = False
Windows("UMOLD.xls").Range("B18").Resize(,4).Copy _ Windows("UMNEW.xls").Range("B16")


My code did that, but lopped around 49 times taking every 19th row.

blackie42
01-21-2008, 06:32 AM
Thanks XLD - now its a bit clearer hopefully I can get it to work

One of those days I think


regards

Jon