+ Reply to Thread
Results 1 to 3 of 3

Writing each XL File Path found in a folder to An XL Sheet in separate cells:

Hybrid View

  1. #1
    Registered User
    Join Date
    07-13-2019
    Location
    Mansehra, Pakistan
    MS-Off Ver
    2010
    Posts
    46

    Writing each XL File Path found in a folder to An XL Sheet in separate cells:

    Hello Everyone!
    The only thing i am unable to do here is somehow write those file paths found through running the following code in an excel sheet in separate cells, preferably using looping or any other simple method.

    Any help would be greatly appreciated.
    Thanks in advance.
    Sub LoopInsideFolder()
    Dim FileDir As String
    Dim Filetolist As String
    Dim r As Long
    
    With Application.FileDialog(msoFileDialogFolderPicker)
        .Title = "Please Select a Folder"
        .ButtonName = "Pick Folder"
        If .Show = 0 Then
            MsgBox "Nothing was Selected"
            Exit Sub
        Else
            FileDir = .SelectedItems(1) & "\"
           
        End If
    End With
            Filetolist = Dir(FileDir & "*xls*")
            Do Until Filetolist = ""
                Filetolist = Dir
            Loop
            
    End Sub

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,461

    Re: Writing each XL File Path found in a folder to An XL Sheet in separate cells:

    here is one way, start cell is A1 of activesheet

    Sub LoopInsideFolder()
    Dim FileDir As String
    Dim Filetolist As String
    Dim r As Long
    Dim output As Range
    
    With Application.FileDialog(msoFileDialogFolderPicker)
        .Title = "Please Select a Folder"
        .ButtonName = "Pick Folder"
        If .Show = 0 Then
            MsgBox "Nothing was Selected"
            Exit Sub
        Else
            FileDir = .SelectedItems(1) & "\"
           
        End If
    End With
            Set output = Range("A1")
            Filetolist = Dir(FileDir & "*xls*")
            Do Until Filetolist = ""
                output = Filetolist
                Set output = output.Offset(1, 0)
                Filetolist = Dir
            Loop
            
    End Sub
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    07-13-2019
    Location
    Mansehra, Pakistan
    MS-Off Ver
    2010
    Posts
    46

    Re: Writing each XL File Path found in a folder to An XL Sheet in separate cells:

    Many Thanks Andy!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Separate complete path to file and directory path
    By drgkt in forum Excel General
    Replies: 19
    Last Post: 10-28-2016, 04:17 PM
  2. Replies: 2
    Last Post: 12-29-2015, 04:19 AM
  3. Master data should get in another sheet in separate file in a folder
    By santbiju1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-18-2015, 03:09 AM
  4. Choosing folder path (instead of file path) in VBA
    By sminter in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-23-2014, 08:50 PM
  5. Code to list the folder path and sub folder path of a specific file
    By kalai1587 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2013, 03:51 AM
  6. Specified folder path to select file path
    By JayEmTee91 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2012, 10:38 AM
  7. macro to list file name and path in separate cells
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2006, 11:20 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