+ Reply to Thread
Results 1 to 2 of 2

Importing multiple .del files into .csv file

  1. #1
    Registered User
    Join Date
    05-21-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Importing multiple .del files into .csv file

    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
    Last edited by Tomsnape; 05-21-2012 at 06:04 AM. Reason: solved 1 part

  2. #2
    Registered User
    Join Date
    05-21-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Importing multiple .del files into .csv file

    This message is solved now

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1