PDA

View Full Version : Copying to multiple workbook coding..



perbags
06-24-2010, 01:49 AM
Hello..

Can anyone help me with the following excel vba coding...

I have three workbooks and what I need it to do is to look at sheet on worksheet one, look at columns A to U starting on row 7 and delete the the data down until in all cleared.

Now it looks at workbook2 sheet1, look at columns A to U starting on row 7 and copies all the data down untill it gets to the a emplty row, thens paste this all this wookseet1. Then looks at worksheets2 sheet2, and copies the same as above into the next empty row in workbook1.

It then looks at workbook3 and copies the same as workbook2 into workbook1....

Does anyone have a idea on the coding for this task...

Thanks inadvanced for the help on this ...

Aussiebear
06-24-2010, 02:08 AM
Have you tried to record these events using the macro recorder?

perbags
06-24-2010, 02:40 AM
Have you tried to record these events using the macro recorder?

Thought of this but this but the issue is that it good for clearing the data on worksheet1, then copying to from the worksheet2 sheet1, but when copying from sheet2 it finding the next empty row after what been pasted from the first sheet1.:dunno

Aussiebear
06-24-2010, 02:56 AM
I can't follow the logic of your reasoning in post #3. You've started to explain that you thought of this but this...... and then ramble on to the logic of the process. If you try to record the process by using the macro recorder, you then have some code to play around with. We then can look at your supplied code and amend where necessary until it works to your satisfaction. This is the logic behind my request.

perbags
06-24-2010, 04:00 AM
Here is a copy of the macro created for my coding so far...




Sub copyandpaste()
Range("A3:U2000").Select
Selection.ClearContents
Windows("Service_Issue_Logv1.0_ABER.xls").Activate
Sheets("unresolved").Select
Range("A7:U30").Select
Range("U30").Activate
Selection.Copy
Windows("DP_EOD_TREENDS_2010.xls").Activate
Range("A3").Select
ActiveSheet.Paste
Windows("Service_Issue_Logv1.0_ABER.xls").Activate
Sheets("resolved").Select
Range("A7:U30").Select
Range("U7").Activate
Selection.Copy
Windows("DP_EOD_TREENDS_2010.xls").Activate
ActiveSheet.Paste
Windows("Service_Issue_Logv1.0_ABER.xls").Activate
ActiveWindow.Close
Range("A7:U32").Select
Range("U7").Activate
Selection.Copy
Windows("DP_EOD_TREENDS_2010.xls").Activate
ActiveSheet.Paste
Range("A77").Select
Windows("Service_Issue_Logv1.0_ASTO.xls").Activate
Sheets("resolved").Select
Range("A7:U17").Select
Range("U7").Activate
Selection.Copy
Windows("DP_EOD_TREENDS_2010.xls").Activate
ActiveSheet.Paste
Range("A88").Select
Windows("Service_Issue_Logv1.0_ASTO.xls").Activate
ActiveWindow.Close
Range("A66").Select
End Sub


The issue from this are..

1, I am selecting the range from my worksbooks manually but I will not know the range to paste because some days there are 2 rows to paste and the following day could be 20 rows so I need the marco to only copy the rows that have data in..

2, When pasting into the main workbook I need to look for next empty row to copy the pasted data into.

Hope this make more sense and thanks for your help.

Simon Lloyd
06-25-2010, 01:17 AM
Perbags, please read the link in my signature with regards crossposting!

Crossposted at least here http://www.excelforum.com/excel-programming/733407-if-value-found-copy-range.html#post2325937