Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.39 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. how to read certain files in a directory in excel VBA
  2. Sub GetFiles()
  3.     Dim strFolder As String
  4.     Dim strFileName As String
  5.     Dim wb As Workbook
  6.     strFolder = "C:temp"
  7.     strFileName = Dir(strFolder & "*123.xls")
  8.     Do While Len(strFileName) > 0
  9.         Set wb = Workbooks.Open(strFileName)
  10.         Debug.Print wb.FullName
  11.         wb.Close False
  12.         strFileName = Dir
  13.     Loop
  14. End Sub