Results 1 to 3 of 3

Thread: DIR Function

  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Using strFilename = Dir("" & oPath & "\6*.xls", vbHidden) one can recurse through a directory looking for files that begin with a 6.

    Is it possible to recurse through the directory and look for files that do not begin with a 4,5 or 6?


    Thanks,
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You can't specify that in the Dir instruction itself. You should specify *.xls and test the filename within the loop:

    Code:
    Select Case UCase(Left(strFilename, 1))
      Case "4", "5", "6"
    	' Skip
      Case Else
    	' Code to process the file
    	...
    End Select

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hans,

    I was leaning towards your suggestion but I thought I would ask.

    Regards,
    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •