title: How to import data from several txt files
body: <p>I am still fairly new to vba and have a question regarding data import. I have the following code (below) to import and transpose data from a textfile, however it would be nice to be able to highlight fx five files and then importing them. I guess I need multiselect but how do I get the script to run through all selected files? </p>
  
  <p>Hope you can help med.</p>
  
  <p>Best Regards</p>
  
  <p>Lonnie</p>
  
  <pre><code>FILOPEN = Application.GetOpenFilename("Files (*.txt; *.jpg; *.bmp;   
  
  *.tif),*.chr; *_chr.txt; *chr.txt; *.tif", _
   , "Select Picture to Import")
   On Error GoTo LastLine
  
  Application.ScreenUpdating = False
      Workbooks.OpenText Filename:=FILOPEN, _
      Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
          xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, _
          Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
          TrailingMinusNumbers:=True
  
  'name of file that is imported from
  Dim z As String
  
  z = ActiveWorkbook.Name   
  Windows(Left(z, Len(z))).Activate
  
  'Copy Data
  Range("c1").Select
  
      Selection.End(xlDown).Select
      ActiveCell.Offset(1, 0).Range("A1").Select
      Range(Selection, Selection.End(xlDown)).Select
      Selection.Copy
  
  
  Windows(Left(f, Len(f))).Activate 'name of file that is imported into (original sheet)
  
      ActiveCell.Offset(0, 1).Range("A1").Select
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
          :=False, Transpose:=True
  
      Selection.End(xlToLeft).Select
      ActiveCell.Offset(0, 0).Range("A1").Select
  </code></pre>