Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Lydia Hughes   on Oct 10 In MS Office Category.

  
Question Answered By: Dylan Evans   on Oct 10

I want to write  a macro which fetches data  from two different workbooks and copies into another third work book which is generated runtime.I tried to record the macro for the procedure which I do manually...and which I have to auto mate now.
here is what I do:
Here is the code i got when I recorded Macro.I used two work book.
1. I opened both work books from which I wanted data, and started recording macro in both of them.Now, from first work book I copied the column i wanted to copy  and then out of same work book opened another work book and pasted stuff in it.
2. From second work book, I copied and pasted one column each from three different work sheets to the new work book i previously opened.
3. I saved my work book as combineddata.xls.
4. closed previous all the work books.


here is the Macro which I recorded:

Here is the Macro I get.I have also attached the file.

Sub FirstMacro()
'
' FirstMacro Macro
' Macro recorded 8/22/2004 by roomies
'
'
Range("R2").Select
Application.WindowState = xlMinimized
Windows("Renewal Sales Dashboard French.xls").Activate
Workbooks.Add
Application.WindowState = xlMinimized
Windows("Renewal Sales Dashboard French.xls").Activate
Range("D3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste
Windows("Sales Report RQ August.xls").Activate
Sheets("Initial Owner").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
Range("B1").Select
ActiveSheet.Paste
Windows("Sales Report RQ August.xls").Activate
Sheets("Second Owner").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
Range("C1").Select
ActiveSheet.Paste
Windows("Sales Report RQ August.xls").Activate
Sheets("Combined").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
Range("D1").Select
ActiveSheet.Paste
Windows("Renewal Sales Dashboard French.xls").Activate
End Sub

I have to automate above macro to copy arrays of any length.
Any Idea,
This is kind  of SOS.

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on file copy Or get search suggestion and latest updates.


Tagged: