I have about 400 Excel files each containing four sheets. Each file is formatted the same way.
I would like to extract values from specific cells from the first three sheets in each file and paste these values into a new master workbook with a row for each file, recording the file name in a column at the front of each row.
I have using a limited macro and copy and paste.
My process
- Open the excel file
- Make a new sheet
- Run the macro below
- Copy and paste the macro output into a separate master workbook and type the file name in the adjacent column.
Sub Research_data_extraction_macro()
Research_data_extraction_macro Macro
Keyboard Shortcut: Ctrl+k
Sheets("Day1").Select
Range("F23:I23").Select
Selection.Copy
Sheets("DATA EXTRACTION").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Day1").Select
Range("F24:I24").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA EXTRACTION").Select
Range("E2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Day1").Select
Range("F31:I31").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA EXTRACTION").Select
Range("I2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Day2").Select
Range("F23:I23").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA EXTRACTION").Select
Range("M2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Day2").Select
Range("F24:I24").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA EXTRACTION").Select
Range("Q2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Day2").Select
Range("F31:I31").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA EXTRACTION").Select
Range("U2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Day3").Select
Range("C23:F23").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA EXTRACTION").Select
Range("Y2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Day3").Select
Range("C43:F43").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA EXTRACTION").Select
Range("AC2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Day3").Select
Range("C24:F24").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA EXTRACTION").Select
Range("AG2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Day3").Select
Range("C44:F44").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA EXTRACTION").Select
Range("AK2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Day3").Select
Range("C51:F51").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA EXTRACTION").Select
Range("AO2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
What would I need to add to run these steps on multiple files without opening them each time?
Is there a way to extract the file name and place it in a column next to each row?