Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Sample()
- 'File: c:\file1.txt,c:\file2.txt
- Dim Filelist() As Variant
- Filelist = Array("file1", "file2")
- Dim wbI As Workbook, wbO As Workbook
- Dim wsI As Worksheet
- Set wbI = ThisWorkbook
- Dim Inx As Long
- For Inx = LBound(Filelist) To UBound(Filelist)
- Debug.Print Filelist(Inx)
- '-----Import for Sheet
- Set wsI = wbI.Sheets(Filelist(Inx)) '<~~ Sheet where you want to import
- Set wbO = Workbooks.Open("C:\" & Filelist(Inx) & ".txt")
- wbO.Sheets(1).Cells.Copy wsI.Cells
- wbO.Close SaveChanges:=False
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment