ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   importing textfiles with cariagge returns into 1 cell (https://www.excelbanter.com/excel-programming/299025-importing-textfiles-cariagge-returns-into-1-cell.html)

zZyXx

importing textfiles with cariagge returns into 1 cell
 
Column A has names of textfiles that need to be imported into collum
B.

zZyXx[_2_]

importing textfiles with cariagge returns into 1 cell
 
this seems to do the trick:

Dim InputString As String, FileNum As Integer
colIndex = 1
For rwIndex = 1 To 10
With ActiveSheet.Cells(rwIndex, colIndex)
FileName = "S:\sekretnew\server\brief\04IN\SE\109\boodsch ap\"
Mid(.Value, 3) + ".txt"
End With
FileNum = FreeFile ' next free filenumber
Open FileName For Input As #FileNum
Line Input #FileNum, FileContent ' read a line from the textfile
While Not EOF(FileNum)
Line Input #FileNum, InputString ' read a line from th
textfile
FileContent = FileContent + Chr(10) + InputString
Wend
Close #FileNum
ActiveSheet.Cells(rwIndex, 2).Value = FileContent
Next rwInde

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 04:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com