+ Reply to Thread
Results 1 to 2 of 2

find a folder on a partial match

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    find a folder on a partial match

    The path is known to a point:
    "C:\QSM\MCR\CMCR"

    I need to locate a subfolder in the above folder

    The folder name may be any length but the first 6 characters are known.

    However, the folder may not exist.

    Is there a way to determine IF a folder exists, AND it's full name using only a partial match?

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: find a folder on a partial match

    You may try something like this....
    Sub FindFolder()
    Dim fso As Object
    Dim Folder As Object
    Dim subFolder As Object
    Dim folderPath As String
    Dim partFolderName As String
    Dim found As Boolean
    Set fso = CreateObject("Scripting.FileSystemObject")
    folderPath = "C:\QSM\MCR\CMCR"
    partFolderName = "< String to check in sub-folder's name >"      'Replace < String to check in sub-folder's name > with known string from the sub-folder's name
    Set Folder = fso.GetFolder(folderPath)
    For Each subFolder In Folder.SubFolders
       If subFolder.Name Like "*" & partFolderName & "*" Then
          MsgBox subFolder.Name
          Exit For
       End If
    Next subFolder
    End Sub
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

+ 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] Find partial match between two columns and highlight cells that match
    By TomToms in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-18-2019, 01:07 PM
  2. Replies: 27
    Last Post: 06-15-2016, 01:05 PM
  3. find data based on partial match
    By mikoski in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-08-2015, 08:47 AM
  4. [SOLVED] Find the row number with a partial match to text in column A
    By zookeepertx in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-10-2014, 01:39 PM
  5. Find Partial Text Match between Two Columns of data
    By samybelen in forum Excel General
    Replies: 1
    Last Post: 10-23-2013, 01:45 PM
  6. Find folder path with partial information
    By superdonk in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-07-2013, 09:15 AM
  7. 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

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