Results 1 to 5 of 5

Import multiply CSV files

Threaded View

  1. #1
    Registered User
    Join Date
    10-18-2019
    Location
    Bielsko, Poland
    MS-Off Ver
    MS Office 2007
    Posts
    3

    Question Import multiply CSV files

    Hi,

    I have got a few CSV file in one folder and I use code (et the end of this post) to import this files:

    I changes .TextFilePlatform = 437 on xlWindows, set .TextFileSemicolonDelimiter = True and switched off .TextFileOtherDelimiter = False

    Almost all works good, but if one cell in CSV file contains a F letter, macro insert an empty cell and remove F. Example:

    CSV file
    Mark;Smith;Poland
    Peter;Friend;Poland

    will be import:
    Mark;Smith;Poland
    Peter;[HERE IS AN EMPTY CELL];riend;Poland

    Why it is works like that? I was looking for an answer in internet but without result.

    Best regards
    Grzegorz

    Code from link I give below:
    Sub LoadPipeDelimitedFiles()
    'UpdatebyKutoolsforExcel20151214
        Dim xStrPath As String
        Dim xFileDialog As FileDialog
        Dim xFile As String
        Dim xCount As Long
        On Error GoTo ErrHandler
        Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
        xFileDialog.AllowMultiSelect = False
        xFileDialog.Title = "Select a folder [Kutools for Excel]"
        If xFileDialog.Show = -1 Then
            xStrPath = xFileDialog.SelectedItems(1)
        End If
        If xStrPath = "" Then Exit Sub
        Application.ScreenUpdating = False
        xFile = Dir(xStrPath & "\*.txt")
        Do While xFile <> ""
            xCount = xCount + 1
            Sheets(xCount).Select
            With ActiveSheet.QueryTables.Add(Connection:="TEXT;" _
              & xStrPath & "\" & xFile, Destination:=Range("A1"))
                .Name = "a" & xCount
                .FieldNames = True
                .RowNumbers = False
                .FillAdjacentFormulas = False
                .PreserveFormatting = True
                .RefreshOnFileOpen = False
                .RefreshStyle = xlInsertDeleteCells
                .SavePassword = False
                .SaveData = True
                .AdjustColumnWidth = True
                .RefreshPeriod = 0
                .TextFilePromptOnRefresh = False
                .TextFilePlatform = 437
                .TextFileStartRow = 1
                .TextFileParseType = xlDelimited
                .TextFileTextQualifier = xlTextQualifierDoubleQuote
                .TextFileConsecutiveDelimiter = False
                .TextFileTabDelimiter = False
                .TextFileSemicolonDelimiter = False
                .TextFileCommaDelimiter = False
                .TextFileSpaceDelimiter = False
                .TextFileOtherDelimiter = "|"
                .TextFileColumnDataTypes = Array(1, 1, 1)
                .TextFileTrailingMinusNumbers = True
                .Refresh BackgroundQuery:=False
                xFile = Dir
            End With
        Loop
        Application.ScreenUpdating = True
        Exit Sub
    ErrHandler:
        MsgBox "no files txt", , "Kutools for Excel"
    End Sub
    Last edited by alansidman; 10-18-2019 at 04:29 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Import two txt files in excel and highlights the differece b/w two files data
    By Imran/CVT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2019, 03:43 AM
  2. Iterative process to import multiple text files into multiple excel files
    By Ecth3lion in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2018, 01:04 PM
  3. Import Macro to import separate files to separate worksheets - deletes existing worksheets
    By Hondahawkrider in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2015, 02:24 PM
  4. [SOLVED] Macro to Import Multiple TXT Files into workbook - User to select files/directory
    By saber007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-15-2013, 08:43 PM
  5. Noob 4 Help - Macro to LIST ALL FILES IN FOLDER and then IMPORT ALL LISTED FILES
    By StlSmiln in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-25-2012, 04:02 AM
  6. [SOLVED] Can i import .csv files into Outlook as sep files
    By joe41 in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 03-25-2009, 04:39 AM

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