Macro to get specific cell data from multiple workbooks

Apokalipto

New Member
Joined
Dec 10, 2018
Messages
7
Hi to everyone, i have searched around to find the specific macro that i can use to solve my issue but nothing works, so i need a modified macro to help me get cell values from multiple files in one folder C:\workbooks (.xclx) the concrete cells i need to get data from are A1 E59 E60 etc. (i will modify this one to apply i just need working example) the work books are all same and the sheet name is same example: XXXXX

EDIT:
Forgot to mention that the data from each workbook must come in new row.
 
Last edited by a moderator:
Could upload a copy of your destination file and one or two of your source files to a free site such as www.box.com or www.dropbox.com. Once you do that, mark each file for 'Sharing' and you will be given a link to each file that you can post here. If the workbooks contains confidential information, you could replace it with generic data.
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Change the sheet name in the source workbooks to "Sheet1" and try this macro:
Code:
Sub CopyRange()
    Application.ScreenUpdating = False
    Dim wsDest As Worksheet, wsSrc As Worksheet, wkbSrc As Workbook
    Set wsDest = ThisWorkbook.Sheets("Sheet1")
    Const strPath As String = "C:\workbooks\"
    ChDir strPath
    strExtension = Dir(strPath & "*.xlsx")
    Do While strExtension <> ""
        Set wkbSrc = Workbooks.Open(strPath & strExtension)
        Set wsSrc = Sheets("Sheet1")
        With wsSrc
            .Range("A1").Copy wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1, 0)
            .Range("E58:E64").Copy
            wsDest.Cells(wsDest.Rows.Count, "B").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True, Paste:=xlPasteValues
            .Range("H58:H64").Copy
            wsDest.Cells(wsDest.Rows.Count, "I").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True, Paste:=xlPasteValues
            .Range("K58:K64").Copy
            wsDest.Cells(wsDest.Rows.Count, "P").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True, Paste:=xlPasteValues
            .Range("N58:N64").Copy
            wsDest.Cells(wsDest.Rows.Count, "W").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True, Paste:=xlPasteValues
            .Range("Q58:Q64").Copy
            wsDest.Cells(wsDest.Rows.Count, "AD").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True, Paste:=xlPasteValues
        End With
        wkbSrc.Close savechanges:=False
        strExtension = Dir
    Loop
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
We have a winner!
Change the sheet name in the source workbooks to "Sheet1" and try this macro:
Code:
Sub CopyRange()
    Application.ScreenUpdating = False
    Dim wsDest As Worksheet, wsSrc As Worksheet, wkbSrc As Workbook
    Set wsDest = ThisWorkbook.Sheets("Sheet1")
    Const strPath As String = "C:\workbooks\"
    ChDir strPath
    strExtension = Dir(strPath & "*.xlsx")
    Do While strExtension <> ""
        Set wkbSrc = Workbooks.Open(strPath & strExtension)
        Set wsSrc = Sheets("Sheet1")
        With wsSrc
            .Range("A1").Copy wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1, 0)
            .Range("E58:E64").Copy
            wsDest.Cells(wsDest.Rows.Count, "B").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True, Paste:=xlPasteValues
            .Range("H58:H64").Copy
            wsDest.Cells(wsDest.Rows.Count, "I").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True, Paste:=xlPasteValues
            .Range("K58:K64").Copy
            wsDest.Cells(wsDest.Rows.Count, "P").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True, Paste:=xlPasteValues
            .Range("N58:N64").Copy
            wsDest.Cells(wsDest.Rows.Count, "W").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True, Paste:=xlPasteValues
            .Range("Q58:Q64").Copy
            wsDest.Cells(wsDest.Rows.Count, "AD").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True, Paste:=xlPasteValues
        End With
        wkbSrc.Close savechanges:=False
        strExtension = Dir
    Loop
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,356
Messages
6,124,475
Members
449,164
Latest member
Monchichi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top