Advertisement
Guest User

Untitled

a guest
Jun 14th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub ImportFiles()
  2.     Dim myFolder As String, myFile As String
  3.     Dim hf As Integer: hf = FreeFile
  4.     Dim lines() As String, i As Long, row As Integer, column As Integer
  5.     myFolder = Application.FileDialog(msoFileDialogFolderPicker)
  6.     With Application.FileDialog(msoFileDialogFolderPicker)
  7.         .AllowMultiSelect = False
  8.         .Show
  9.         If .SelectedItems.Count > 0 Then
  10.             myFolder = .SelectedItems(1)
  11.         End If
  12.     End With
  13.  
  14.     column = 0
  15.     myFile = Dir(myFolder & "\*.txt")
  16.     Do While myFile <> ""
  17.         myFile = myFolder + "\" + myFile
  18.         Open myFile For Input As #hf
  19.             lines = Split(Input$(LOF(hf), #hf), vbNewLine)
  20.         Close #hf
  21.         row = 0
  22.         For i = 0 To UBound(lines)
  23.             MsgBox (lines(i))
  24.             row = row + 1
  25.         Next
  26.         myFile = Dir
  27.         column = column + 1
  28.     Loop
  29.    
  30. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement