Results 1 to 19 of 19

copy rows from 42 workbooks into masterworkbook

Threaded View

  1. #1
    Registered User
    Join Date
    10-03-2012
    Location
    oslo
    MS-Off Ver
    Excel 2010
    Posts
    16

    copy rows from 42 workbooks into masterworkbook

    Hey

    I,m looking for a more elegant solution to the macro pasted below. The idea is to copy 6 rows from 42 workbooks in one single workbook without having to copy the below macro 42 times. All files will be in one folder. So the steps will be:

    1 open first workbook
    2 mark rows
    3 copy rows
    4 insert into active workbook
    5 close workbook
    6 repeat 42 times with every file in directory

        Workbooks.Open Filename:= _
            "\\c\folder\filename 1.xlsm"
        Range("13:15,30:32").Select
        Range("A30").Activate
        Selection.EntireRow.Hidden = False
        Selection.Copy
        Windows("Book1").Activate
        Rows("3:3").Select
        ActiveSheet.Paste
        Windows("filename 1.xlsm").Activate
        Range("B4").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book1").Activate
        Range("A3:A8").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Windows("filename 1.xlsm").Activate
        ActiveWindow.Close
        
        Workbooks.Open Filename:= _
            "\\c\foldername\filename 2.xlsm"
        Range("13:15,30:32").Select
        Range("A30").Activate
        Selection.EntireRow.Hidden = False
        Selection.Copy
        Windows("Book1").Activate
        Rows("9:9").Select
        ActiveSheet.Paste
        Windows("Trafikkinntektsmodell B2013 AT.xlsm").Activate
        Range("B4").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book1").Activate
        Range("A9:A14").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Windows("filename 2.xlsm").Activate
        ActiveWindow.Close
    Last edited by JBeaucaire; 10-03-2012 at 02:53 PM. Reason: Added code tags, as per forum rules. Don't forget!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1