Excel VBA Macro: Extract Data from All Files in a (User Selected) Folder

  Рет қаралды 8,345

greggowaffles

greggowaffles

Күн бұрын

Excel VBA Macro: Extract Data from All Files in a (User Selected) Folder
💥Subscribe: / @greggowaffles
Code:
Sub grab_data_from_files_in_folder()
Dim myPath As String
Dim myFile As String
Dim FldrPicker As FileDialog
Dim sh As Worksheet
Dim i As Integer
Application.ScreenUpdating = False
Set sh = ThisWorkbook.Sheets("Team Summary")
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Please Select Folder"
.AllowMultiSelect = False
.ButtonName = "Confirm!!"
If .Show = -1 Then
myPath = .SelectedItems(1) & "\"
Else
End
End If
End With
With sh
.Cells.ClearContents
.Cells(1, 1) = "Team Name"
.Cells(1, 1).Font.Size = 14
.Cells(1, 1).Font.Bold = True
.Cells(1, 2) = "Total Sales"
.Cells(1, 2).Font.Size = 14
.Cells(1, 2).Font.Bold = True
End With
myFile = Dir(myPath)
i = 2
Do While myFile <> ""
Workbooks.Open Filename:=myPath & myFile
sh.Cells(i, 1) = ActiveWorkbook.Sheets("Team Sales").Cells(1, 2).Text
sh.Cells(i, 2) = ActiveWorkbook.Sheets("Team Sales").Cells(2, 2).Value
ActiveWorkbook.Close savechanges:=False
myFile = Dir
i = i + 1
Loop
Application.ScreenUpdating = True
End Sub
#excelmacro #excelvba

Пікірлер: 17
Excel VBA Macro: List All Files (From a Selected Folder)
8:43
greggowaffles
Рет қаралды 9 М.
Copying Data from User Selected Files Using GetOpenFilename
10:26
Excel Macro Mastery
Рет қаралды 19 М.
Dad gives best memory keeper
01:00
Justin Flom
Рет қаралды 20 МЛН
拉了好大一坨#斗罗大陆#唐三小舞#小丑
00:11
超凡蜘蛛
Рет қаралды 16 МЛН
هذه الحلوى قد تقتلني 😱🍬
00:22
Cool Tool SHORTS Arabic
Рет қаралды 93 МЛН
Excel VBA Macro: Autofilter And Copy to New Workbook (Dynamic Range)
14:08
Loop Through All Files in a Folder Using VBA/Macros in Excel
13:41
Excel VBA: Copy Data Between ANY Two Sheets
12:56
Excel Macro Mastery
Рет қаралды 120 М.
How To Master Arrays In Excel VBA + FREE MACROS & CHEAT SHEET
29:09
Excel For Freelancers
Рет қаралды 7 М.
Excel VBA Macro: Progress Bar While Macro is Running (UserForm)
11:51