I'm using the macro below to import and arrange the contents of all of the.csv files from a specific directory (C:\csv) on an excel worksheet. I would like the macro to import all of the .csv files in the subdirectories also. If a browser window could open and let me select the path for all of the .csv files I want to import, that would be fantastic. Thank you in advance!
Dim wbCSV   As Workbook
Dim wsMstr  As Worksheet:   Set wsMstr = Sheet1
Dim fPath   As String:      fPath = "C:\csv\"    'path to CSV files
Dim fCSV    As String
If MsgBox("Clear the existing MasterCSV sheet before importing?", vbYesNo, "Clear?") _
    = vbYes Then wsMstr.UsedRange.Clear
Application.ScreenUpdating = False  'speed up macro
fCSV = Dir(fPath & "*.csv")         'start the CSV file listing
    Do While Len(fCSV) > 0
      'open a CSV file
        Set wbCSV = Workbooks.Open(fPath & fCSV)
      'insert col A and add filename
        Columns(1).insert xlShiftToRight
        Columns(1).insert xlShiftToRight
        Columns(1).insert xlShiftToRight
        Columns(1).insert xlShiftToRight
        Range("E4").Select
        Selection.Copy
        Range("a20:a87").Select
        ActiveSheet.Paste
      'copy date to b column
        Range("E3").Select
        Selection.Copy
        Range("b20:b87").Select
        ActiveSheet.Paste
      'copy sample to c column
        Range("c20:c87").Select
        ActiveCell = "sample"
        Range("c20").Select
        Selection.Copy
        Range("c21:c87").Select
        ActiveSheet.Paste
        'copy 1 to d column
        Range("d20:d87").Select
        ActiveCell = "1"
        Range("d20").Select
        Selection.Copy
        Range("d21:d87").Select
        ActiveSheet.Paste
        'delete header
        Rows("1:20").Select
        Selection.Delete Shift:=xlUp
        'delete un needed columns
        Columns("H:H").Select
        Selection.Delete Shift:=xlToLeft
        Columns("F:F").Select
        Selection.Delete Shift:=xlToLeft
        'copy date into master sheet and close source file
        ActiveSheet.UsedRange.Copy wsMstr.Range("A" & Rows.Count).End(xlUp).Offset(1)
        wbCSV.Close False
      'ready next CSV
        fCSV = Dir
    Loop
Application.ScreenUpdating = True
End Sub
 
     
    