Results 1 to 1 of 1

VBA directory search for files stored on mac & in subfolders

Threaded View

  1. #1
    Registered User
    Join Date
    07-26-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    1

    VBA directory search for files stored on mac & in subfolders

    Hi everyone

    I have a macro that is not allowing me to search through all folders and (possible/if applicable) sub-folders. I have no idea how to achieve this.
    Can someone help on finalizing the code for me that will allow for a search through all folders and (possible/if applicable) sub-folders in the two specified directories in cell C3 and C7

    Thank you all in advance


    this is the macro mentioned: its stored in module MasterFile:

    Dim vFiles As Variant
    
    
    Sub DossierNummer()
      Dim RimorMacro As String
      Dim mysht As String
    
      Application.ScreenUpdating = False
    
      RimorMacro = ActiveWorkbook.Name
      Sheets("OverzichtInhoud").Select
      Range("A2:Q2" & ActiveSheet.UsedRange.Rows.Count).ClearContents
      Range("A2").Select
    
    
      Sheets("StartPunt").Select
    
    
      get_filename
      Sheets("StartPunt").Select
      lrow = Range("E1", Selection.End(xlDown)).Count
     
      For i = 2 To lrow
        If Range("E" & i).Value = "" Then
          MsgBox "Gegevens staan nu klaar in de OverzichtInhoud!", vbInformation, "Status Kopiëren"
          Exit Sub
        Else
          Workbooks.Open Filename:=vFiles(1, i) & vFiles(2, i)
      
          mysht = ActiveWorkbook.Name
            Application.StatusBar = "Rimor RapportageTool is bezig met het verwerken van: " & mysht
                
                Sheets("Worksheet").Select
                    Range("B4:B10,B29,B20,B24,B30,B31,B32,B33,B34,B35,B36").Select
                        Selection.Copy
                    
          Workbooks(RimorMacro).Activate
          Sheets("OverzichtInhoud").Select
          Selection.PasteSpecial Paste:=xlPasteValues, Transpose:=True
      
          ActiveCell.Offset(0, 0).Select
            Workbooks("" & mysht & "").Activate
                Range("B24").Select
     
    ActiveCell.Offset(0, 0).Select
        Workbooks("" & mysht & "").Activate
            Range("B24").Select
     
    Selection.End(xlDown).Select
    Selection.Copy
    Workbooks("" & RimorMacro & "").Activate
    Selection.PasteSpecial Paste:=xlPasteValues
    ActiveCell.Offset(1, 0).Select
    Application.CutCopyMode = False
    Sheets("StartPunt").Select
          
          Workbooks(mysht).Close SaveChanges:=False
          Workbooks(RimorMacro).Activate
        End If
      Next i
      Application.StatusBar = False
        Application.ScreenUpdating = True
    End Sub
    
    
    
    
    
    Sub get_filename()
      Const sPathRange As String = "C3,C7"
      Const iIncr As Long = 50
    
      Dim fdr As String
      
      ' this range will store your paths
      Dim rngPathList As Excel.Range
      Dim rng As Excel.Range
      
      Dim iSize As Long
    
      iSize = iIncr
      
      mrow = 2
      
      ReDim vFiles(1 To 2, 2 To iSize)
      
      Set rngPathList = Range(sPathRange)
      
      Range(Range("E2"), Range("E2").End(xlDown)).ClearContents
      Range("E2").Select
      
      For Each rng In rngPathList
        spath = rng.Value
        fdr = Dir(spath & "\*Worksheet*.xlsm")
        
        Do While fdr <> ""
          If mrow > iSize Then
            iSize = iSize + iIncr
            ReDim Preserve vFiles(1 To 2, 2 To iSize)
          End If
    
          vFiles(1, mrow) = spath & Application.PathSeparator
          vFiles(2, mrow) = fdr
          
          Cells(mrow, 5).Value = fdr
          
          fdr = Dir
          mrow = mrow + 1
        Loop
        
        If iSize >= mrow Then
          iSize = mrow - 1
          ReDim Preserve vFiles(1 To 2, 2 To iSize)
        End If
      Next rng
    End Sub

    the file can be found on my googleDrive:
    https://drive.google.com/file/d/0B06...it?usp=sharing


    thanks for your help in advance
    thebute
    Last edited by thebute; 02-22-2014 at 06:01 PM. Reason: Looking for an other solution

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] list of subfolders in folder - without files and sub-subfolders
    By MartyZ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2022, 10:56 AM
  2. Macro that reads *.xls files from a directory and subfolders ***HELP***
    By anaconte1010 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2013, 09:10 AM
  3. Find *.xls files in a directory and run macro(including *.xls located in subfolders)
    By driftlogic in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-12-2012, 11:34 AM
  4. Help w/making this list Parent directory,Subfolders,and files
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-16-2008, 07:09 PM
  5. copy subfolders, replace text in files and save files in copied subfolders
    By pieros in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-01-2005, 09:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1