none
SEARCH SUBFOLDER NAMES for matches RRS feed

  • Question

  • Using below code to monitor a text box and populate a combo box with possible matches. currently searches thru .xlsx files in a folder - works perfectly!!! I need to modify the code to search thru the sub folder names in the folder for matches. Any help would be greatly appreciate.

    Private Sub TextBox2_CHANGE() '<<<FILE SEARCH
    Call NAMEDLIST
    End Sub

    Sub NAMEDLIST() 'LOADS FILES INTO COMBOBOX BASED ON TEXTBOX2
     
     Application.ScreenUpdating = False
        ComboBox1.Clear
       
        MYPATH = MYPATHIS() 'returns c:\user\username\dropbox\doc's\
        strfolder = MYPATH
       
        Dim strFile As String
        Dim oDictionary As Object
        Dim vArray As Variant
        Dim v As Variant
       
        Set oDictionary = CreateObject("Scripting.Dictionary")
        strFile = Dir(strfolder & TextBox2.Text & "*.xlsx") '<<<EDIT HERE???
        While strFile <> ""
            oDictionary(strFile) = strFile
            strFile = Dir
        Wend
       
        vArray = Sort(oDictionary.ITEMS)
        For Each v In vArray
           ComboBox1.AddItem v
        Next
       
        If ComboBox1.ListCount = 0 Then
        MsgBox "NO FILE FOUND"
       
        TextBox2.Text = ""
       
        Call CTBOX
        Call BLANKFILE
        Call FILELIST
       
        Else
        
        ComboBox1.ListIndex = 0
        End If
        
        End Sub

    Friday, December 20, 2019 3:39 PM

Answers

  • Realized that I don't really need to change the code. recently been cleaning up some of the file/folder routines in my application and got into a train of thought that led me to overcomplicate that which was already working. all i need to do is create another subfolder for the .xlsx files and modify my path to read from that. lets just chalk it up to brain freeze!

    that being said if anyone has any thoughts on my post I would appreciate your advise.

    thanks

    Doug

    • Marked as answer by 6da4 Tuesday, December 24, 2019 4:35 PM
    Tuesday, December 24, 2019 4:25 PM