Results 1 to 3 of 3

Importing multiple CSV files into one excel worksheet (Mac Excel)

Threaded View

shibatat Importing multiple CSV files... 08-23-2014, 03:48 AM
redsab Re: Importing multiple CSV... 08-23-2014, 07:34 AM
shibatat Re: Importing multiple CSV... 08-24-2014, 12:24 AM
  1. #2
    Forum Contributor
    Join Date
    05-02-2013
    Location
    Indiana
    MS-Off Ver
    Microsoft 365 (Subscription)
    Posts
    192

    Re: Importing multiple CSV files into one excel worksheet (Mac Excel)

    Shibatat,
    I don't have a Mac, but this is how I do it for my PC.
    Public FSO As New FileSystemObject
    
    Sub Import_Text()
    
        Dim WrdArray() As String
        Dim txtstrm As TextStream
        Dim line, FileName, sName As String
        Dim clm As Long
        Dim Rw As Long
    
        FileName = InputBox("Enter the file name and file location", "Import File")
        sName = InputBox("Enter Sheet Name", "Sheet Name Entry")
        Sheets.Add.Name = sName
        Sheets(sName).Select
        
        Set txtstrm = FSO.OpenTextFile(FileName)
        Rw = 2
        Do Until txtstrm.AtEndOfStream
            line = Replace(txtstrm.ReadLine, Chr(34), Chr(32))
            clm = 1
            WrdArray() = Split(line, ",")
            For Each Wrd In WrdArray()
                Word = Wrd
                ActiveSheet.Cells(Rw, clm) = Wrd
                clm = clm + 1
            Next Wrd
            Rw = Rw + 1
        Loop
        txtstrm.Close
        MsgBox "Data Imported. " & Rw - 3 & " Records Found."
        
    End Sub
    Before accessing the text file you'll need to set up a reference enabling access to the file system. You do this by clicking the tools tab in the VBA code window and selecting the Microsoft Scripting Runtime library. Since you are using a Mac, maybe there is a Scripting Runtime libary for the Mac. I suspect that the code will not work, but maybe it is a start!

    redsab
    Last edited by redsab; 08-23-2014 at 07:36 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Importing Multiple txt files in excel
    By celiojr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2013, 11:00 AM
  2. Replies: 0
    Last Post: 11-27-2012, 01:43 PM
  3. Importing multiple excel files into 1
    By vascobmcastro in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-25-2010, 01:29 PM
  4. Replies: 1
    Last Post: 01-27-2010, 03:06 AM
  5. [SOLVED] Importing from multiple Excel files
    By Tired of wasting time in forum Excel General
    Replies: 2
    Last Post: 09-21-2005, 04:05 PM

Tags for this Thread

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