Macro to Extract Specific cell data from Multiple Worksbooks into one summary.

Dreamwrx

New Member
Joined
Mar 17, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a bunch of excel files (3000) that I need to extract data from specific Cells in these spreadsheet and paste them to a summary sheet.

Q10:V10 -> B8:G8;
Q13:V13 -> H8:M8;
Q16:V16 -> N8-S8;
B14 -> A8

Next Spreadsheet would be
Q10:V10 -> B9:G9;
Q13:V13 -> H9:M9;
Q16:V16 -> N9:S9;
B14 -> A8

so on and so forth.

I have been reading multiple older forum posts and have tried some things but as I am not proficient at VB.. I seem to be stuck.

The following was what I was using. Most of it was from Jerry Beaucaire's code

VBA Code:
Sub Retrieve_Data()
Dim fName As String, fPath As String, fPathDone As String
Dim LR As Long, NR As Long
Dim wbData As Workbook, wsMaster As Worksheet

'Setup
    Application.ScreenUpdating = False  'speed up macro execution
    Application.EnableEvents = False    'turn off other macros for now
    Application.DisplayAlerts = False   'turn off system messages for now
   
    Set wsMaster = ThisWorkbook.Sheets("AVG")    'sheet report is built into

With wsMaster
    If MsgBox("Clear the old data first?", vbYesNo) = vbYes Then
        .UsedRange.Offset(1).EntireRow.Clear
        NR = 2
    Else
        NR = .Range("A" & .Rows.Count).End(xlUp).Row + 1    'appends data to existing data
    End If

'Path and filename (edit this section to suit)
   ' MsgBox "Please select a folder with files to consolidate"
   ' Do
   '     With Application.FileDialog(msoFileDialogFolderPicker)
   '         .InitialFileName = "C:\2010\Test\"
   '         .AllowMultiSelect = False
   '         .Show
   '         If .SelectedItems.Count > 0 Then
   '             fPath = .SelectedItems(1) & "\"
   '             Exit Do
   '         Else
   '             If MsgBox("No folder chose, do you wish to abort?", _
   '                 vbYesNo) = vbYes Then Exit Sub
   '         End If
   '     End With
   ' Loop
   fPath = "C:\Users\htn\Desktop\Macro_Test\"                  'remember final \ in this string
    fPathDone = fPath & "Imported\"     'remember final \ in this string
    On Error Resume Next
        MkDir fPathDone                 'creates the completed folder if missing
    On Error GoTo 0
    fName = Dir(fPath & "*.xls*")       'listing of desired files, edit filter as desired

'Import a sheet from found files
    Do While Len(fName) > 0
        If fName <> ThisWorkbook.Name Then              'don't reopen this file accidentally
            Set wbData = Workbooks.Open(fPath & fName)  'Open file
        'This is the section to customize, replace with your own action code as needed
            Dim ws As Worksheet
            For Each ws In wbData.Sheets(Array("Flow_Level"))
                LR = Range("B" & Rows.Count).End(xlUp).Row  'how many rows of info?
                If LR > 3 Then
                    wsMaster.Range("A" & NR) = Replace(Range("A1"), "Group ", "")
                        Range("Q10:V10").Copy
                    wsMaster.Range("B8" & NR).PasteSpecial xlPasteValues, Transpose:=True
                    wbData.Close False                                'close file
                    NR = wsMaster.Range("B" & Rows.Count).End(xlUp).Row + 1
                End If
   
   
    Next ws
        ' wbData.Close False   'close data workbook
        ' fName = Dir         'get the next filename
        Name fPath & fName As fPathDone & fName           'move file to IMPORTED folder
        End If
        fName = Dir                                       'ready next filename
    Loop
   
    Range("A3:A" & NR - 1).SpecialCells(xlBlanks).FormulaR1C1 = "=R[-1]C"
    With Range("A3:A" & NR - 1)
    .Value = .Value
    End With
End With
ErrorExit:    'Cleanup
    ActiveSheet.Columns.AutoFit
    Application.DisplayAlerts = True         'turn system alerts back on
    Application.EnableEvents = True          'turn other macros back on
    Application.ScreenUpdating = True        'refreshes the screen
End Sub

Thank you for any help in advance.
 
Last edited by a moderator:
Please start a new thread.

@John_w , Here is the thread. Thanks for replying.


 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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