Results 1 to 10 of 10

excel vba case sensitivity in a recursive function problem

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    excel vba case sensitivity in a recursive function problem

    I'm using some code example by Albert Kallall and Browne that uses a recursive function to build a collection of files based on a string search where strFileSpec is set to a wildcard file. srtTemp is the temporary directory being added to the collection if strFileSpec is True. As it is, strFileSpec is case sensitive at the code level, but the files vary in case sensitivity - some are all upper, some all lower, and even some are Proper. Is there a way to set an argument to find a search strFileSpec, regardless of case at the code level?
    Public Function RecursiveDir(colFiles As Collection, _
                                 strFolder As String, _
                                 strFileSpec As String, _
                                 bIncludeSubfolders As Boolean)
    
        Dim strTemp As String
        Dim colFolders As New Collection
        Dim vFolderName As Variant
    
        'Add files in strFolder matching strFileSpec to colFiles
        strFolder = TrailingSlash(strFolder)
        strTemp = Dir(strFolder & strFileSpec)
        Do While strTemp <> vbNullString
            colFiles.Add strFolder & strTemp
            strTemp = Dir
        Loop
    
        If bIncludeSubfolders Then
            'Fill colFolders with list of subdirectories of strFolder
            strTemp = Dir(strFolder, vbDirectory)
            Do While strTemp <> vbNullString
                If (strTemp <> ".") And (strTemp <> "..") Then
                    If (GetAttr(strFolder & strTemp) And vbDirectory) <> 0 Then
                        colFolders.Add strTemp
                    End If
                End If
                strTemp = Dir
            Loop
    
            'Call RecursiveDir for each subfolder in colFolders
            For Each vFolderName In colFolders
                Call RecursiveDir(colFiles, strFolder & vFolderName, strFileSpec, True)
            Next vFolderName
        End If
    
    End Function
    Last edited by terriertrip; 10-17-2020 at 01:02 AM. Reason: syntax

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Case sensitivity with IF statement
    By AceForSale in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-18-2018, 10:31 AM
  2. SQL LIKE case sensitivity issue
    By keyston in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2011, 09:16 AM
  3. write name checking function where case sensitivity does not matter
    By netdude_18 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-23-2008, 01:39 PM
  4. multiple if's and case sensitivity
    By xcelnoob in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-22-2007, 09:54 PM
  5. Using EXACT function without case-sensitivity?
    By Kayote in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-23-2007, 09:53 AM
  6. [SOLVED] VLookup & Case Sensitivity
    By KHogwood-Thompson in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-11-2006, 04:35 AM
  7. Case Sensitivity problem with data validation
    By Upya in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-06-2005, 09:05 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