Results 1 to 3 of 3

Dir Help

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    109

    Dir Help

    I have the following code:

    Option Explicit
    
    Sub Consolidate()
        Dim MyPath As String
        Dim FilesInPath As String
        Dim MyFiles() As String
        Dim Fnum As Long
        Dim mybook As Workbook
        Dim CalcMode As Long
        Dim sh As Worksheet
        Dim ErrorYes As Boolean
        Dim DCLastRow As Integer 'DirectorCopy
        Dim MCLastRow As Integer 'Monthly Compiler
    
        Dim center(18) As String
        center(1) = "Bardstown"
        center(2) = "Bothell"
        center(3) = "VCollinsville"
        center(4) = "El Paso"
        center(5) = "Evansville"
        center(6) = "Greensboro"
        center(7) = "VHeathrow"
        center(8) = "Joplin"
        center(9) = "Kennesaw"
        center(10) = "Lafayette"
        center(11) = "Malvern"
        center(12) = "VManhattan"
        center(13) = "VMansfield"
        center(14) = "VOttawa"
        center(15) = "VPonco City"
        center(16) = "VReno"
        center(17) = "VSioux City"
        center(18) = "VTerra Haute"
        
        Dim FileCount As Long
        Dim ScoringAve As Double
        Dim i As Long
        
           
        'Fill in the path\folder where the files are
        MyPath = "X:\C&A Analysts Team\PF Process\1 Tally & PF's Work in Progress\Centers\"
        
        For i = 1 To 18
            
    '        'Add a slash at the end if the user forget it
    '        If Right(MyPath, 1) <> "\" Then
    '            MyPath = MyPath & "\"
    '        End If
            
            'If there are no Excel files in the folder exit the sub
            FilesInPath = Dir(MyPath & center(i) & "*.xl*")
    FilesInPath is always showing empty for some reason. Am I using Dir wrong? I'm always getting:

    FilesInPath = ""
    What I want is the path to the files. For example, if i = 3 then FilesInPath should look like this:

    FilesInPath = X:\C&A Analysts Team\PF Process\1 Tally & PF's Work in Progress\Centers\VCollinsville\*.xl*
    What am I doing wrong?
    Last edited by bishoposiris; 08-04-2009 at 11:49 AM.

Thread Information

Users Browsing this Thread

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

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