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:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
What works with sample data most often will not work with the actual data. Please be specific as to exactly which cells you want to copy and where you want to paste them. What is the actual sheet name and what is the name of the destination sheet? What is ".xclx"?
 
Upvote 0
.xlsx :))

the target cells are: A1 E58 E59 E60 E61 E62 E63 E64 H58 H59 H60 H61 H62 H63 H64 K58 K59 K60 K61 K62 K63 K64 N58 N59 N60 N61 N62 N63 N64 Q58 Q59 Q60 Q61 Q62 Q63 Q64 E58 E59 E60 E61 E62 E63 E64 the actual sheet name is in Cyrillic and is: вкупна (u will probably have to copy this)

i want them pasted in new excel workbook the name of this one does not matter at all.
 
Upvote 0
Open a new blank workbook and copy/paste this macro into a standard module in the new workbook. Run the macro from there. Change the folder path and sheet names (in red) to suit your needs.
Code:
Sub CopyRange()
    Application.ScreenUpdating = False
    Dim wsDest As Worksheet, wsSrc As Worksheet, wkbSrc As Workbook
    Set wsDest = ThisWorkbook.Sheets("[COLOR="#FF0000"]Sheet1[/COLOR]")
    Const strPath As String = "[COLOR="#FF0000"]C:\workbooks\[/COLOR]"
    ChDir strPath
    strExtension = Dir(strPath & "*.xlsx")
    Do While strExtension <> ""
        Set wkbSrc = Workbooks.Open(strPath & strExtension)
        wsSrc = Sheets("[COLOR="#FF0000"]??????[/COLOR]")
        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
            .Range("H58:H64").Copy
            wsDest.Cells(wsDest.Rows.Count, "I").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
            .Range("K58:K64").Copy
            wsDest.Cells(wsDest.Rows.Count, "P").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
            .Range("N58:N64").Copy
            wsDest.Cells(wsDest.Rows.Count, "W").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
            .Range("Q58:Q64").Copy
            wsDest.Cells(wsDest.Rows.Count, "AD").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
            .Close savechanges:=False
        End With
        strExtension = Dir
    Loop
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
D9gMycx
I have a problem - https://ibb.co/D9gMycx
 
Upvote 0
What error message do you get when you click 'Debug'?
 
Upvote 0
Try:
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)
        wsSrc = Sheets("??????")
        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
            .Range("H58:H64").Copy
            wsDest.Cells(wsDest.Rows.Count, "I").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
            .Range("K58:K64").Copy
            wsDest.Cells(wsDest.Rows.Count, "P").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
            .Range("N58:N64").Copy
            wsDest.Cells(wsDest.Rows.Count, "W").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
            .Range("Q58:Q64").Copy
            wsDest.Cells(wsDest.Rows.Count, "AD").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
        End With
        wkbSrc.Close savechanges:=False
        strExtension = Dir
    Loop
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Is the code working for closed workbooks?

p.s i have even tried to rename the cyrilic name to Sheet1 in few files that i have placed in the directory (removed the rest) but i have the exact same error as posted in the previous post (the screens)
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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