Hi,
Hopefully someone can help me as i am not good at all with coding. My problem is i am trying to import a number of files with extension .del into a .csv file.Below is the code i am currently using which is nearly correct but needs some small adjustments. The problem is that the information contained in each file is just saved to 1 cell rather than individual cells.
(E.g) First file imported has file name in A1 and the information in A2. I am looking to get the file name in A1 but the information to be spread across from A2 to A17
Hopefully it is just a small adjustment in the code.
The code i am currently using is
Sub test()
Dim myDir As String, fn As String, txt As String
Dim a(), n As Long, t As Long, x, i As Long
myDir = "C:\Users\tom\Desktop\New folder\"
fn = Dir(myDir & "*.del")
Do While fn <> ""
txt = CreateObject("Scripting.FileSystemObject") _
.OpenTextFile(myDir & fn).ReadAll
n = n+ 1: t = 1
ReDim Preserve a(1 To 10000, 1 To 2000)
a(n, t) = Split(fn, ".")(0)
x = Split(txt, vbCrLf)
For i = 0 To UBound(x)
n = n + 1
a(n, t) = x(i)
Next
fn = Dir
Loop
If t > 0 Then
Sheets(1).Cells(1).Resize(10000, t).Value = a
Else
MsgBox "No file"
End If
End Sub
Bookmarks