CutterSoilMixing
New Member
- Joined
- Jun 8, 2019
- Messages
- 17
- Office Version
- 365
- Platform
- Windows
Hello everyone,
I regularly have to update a master spreadsheet with data from multiple excel files. The excel files are all in the same format and the data I need is always in the same cells and sheet (sheet 1). The files are also always stored in the same folder. I have a code that allows me to select each file individually and then copies the data I need into the master. I was wondering if there is a way to copy the data from all files in the folder at the same time so that I only select the folder instead every single file?
Thanks for your help!
I regularly have to update a master spreadsheet with data from multiple excel files. The excel files are all in the same format and the data I need is always in the same cells and sheet (sheet 1). The files are also always stored in the same folder. I have a code that allows me to select each file individually and then copies the data I need into the master. I was wondering if there is a way to copy the data from all files in the folder at the same time so that I only select the folder instead every single file?
Thanks for your help!
VBA Code:
Private Sub CommandButton1_Click()
Dim FileLocation As String
FileLocation = Application.GetOpenFilename
If FileLocation = "False" Then
Beep
Exit Sub
End If
Application.ScreenUpdating = False
Set ImportWorkbook = Workbooks.Open(Filename:=FileLocation)
'date'
ImportWorkbook.Worksheets("sheet1").Range("B6").Copy ThisWorkbook.Worksheets("data").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
'panel id'
ImportWorkbook.Worksheets("sheet1").Range("B5").Copy ThisWorkbook.Worksheets("data").Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
'start time'
ImportWorkbook.Worksheets("sheet1").Range("B7").Copy ThisWorkbook.Worksheets("data").Range("C" & Rows.Count).End(xlUp).Offset(1, 0)
'final depth'
ImportWorkbook.Worksheets("sheet1").Range("B33").Copy ThisWorkbook.Worksheets("data").Range("D" & Rows.Count).End(xlUp).Offset(1, 0)
'end time'
ImportWorkbook.Worksheets("sheet1").Range("B33").Copy ThisWorkbook.Worksheets("data").Range("E" & Rows.Count).End(xlUp).Offset(1, 0)
'cut depth'
ImportWorkbook.Worksheets("sheet1").Range("B43").Copy ThisWorkbook.Worksheets("data").Range("F" & Rows.Count).End(xlUp).Offset(1, 0)
'rig'
ImportWorkbook.Worksheets("sheet1").Range("B56").Copy ThisWorkbook.Worksheets("data").Range("I" & Rows.Count).End(xlUp).Offset(1, 0)
'total slurry'
ImportWorkbook.Worksheets("sheet1").Range("B35").Copy ThisWorkbook.Worksheets("data").Range("H" & Rows.Count).End(xlUp).Offset(1, 0)
'operator'
ImportWorkbook.Worksheets("sheet1").Range("B4").Copy ThisWorkbook.Worksheets("data").Range("J" & Rows.Count).End(xlUp).Offset(1, 0)
ImportWorkbook.Close
Application.ScreenUpdating = True
End Sub