Results 1 to 22 of 22

Find folder path for string in cell

Threaded View

  1. #1
    Registered User
    Join Date
    08-20-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2013
    Posts
    95

    Question Find folder path for string in cell

    As a preface, I tried to search for the solution to this for a while and was able to come up with some code, but it doesn't quite solve the issue.

    Sub a_filepath()
    
    Dim fpath As String
    Dim filepath As String
    
    fpath = "C:\Users\name\directory 1\"
    filepath = Dir(fpath, vbDirectory)
    
    
    Do Until filepath = ""
        For i = 2 To 5
            If InStr(1, filepath, Range("C" & i)) > 0 Then
                Range("D" & i).Value = fpath & filepath
            End If
        Next i
        filepath = Dir()
    Loop
    
    End Sub
    The problem I'm having with this is that it doesn't go further into the folders within the specified folder. In other words if the directory was "C:\Users\name\directory 1\", and the folder was in "C:\Users\name\directory 1\directory 2\directory 3\folder", I'd like it to go in there and find it.

    Is there any way to do this?
    Last edited by efarkouh; 07-25-2016 at 10:56 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help with Macro to find full path of Folder, using input of first 4 chars of folder name
    By Anxiety in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-28-2015, 09:02 AM
  2. Find latest modified folder and return path to cell
    By dave1983 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2014, 05:27 AM
  3. 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
  4. Find folder path with partial information
    By superdonk in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-07-2013, 09:15 AM
  5. Find File with partial filename and get path of folder
    By axisambrosia in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-16-2012, 06:51 AM
  6. using cell contents as a string to define a folder path
    By RDS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2012, 04:16 PM

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