Results 1 to 7 of 7

import csv macro for excel 2000 and up

Threaded View

catchg import csv macro for excel... 02-17-2013, 03:35 PM
JBeaucaire Re: import csv macro for... 02-18-2013, 12:36 AM
catchg Re: import csv macro for... 02-18-2013, 01:36 PM
JBeaucaire Re: import csv macro for... 02-18-2013, 03:53 PM
catchg Re: import csv macro for... 02-19-2013, 01:23 PM
catchg Re: import csv macro for... 03-20-2013, 07:45 PM
JBeaucaire Re: import csv macro for... 03-20-2013, 07:48 PM
  1. #1
    Registered User
    Join Date
    02-13-2013
    Location
    Florida, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    import csv macro for excel 2000 and up

    I have a macro assigned to a button that is used to import a csv file into an existing sheet named "Data". The macro was created using Excel 2010. I would like the macro to also work in all previous versions back to Excel 2000. Is it possible to adapt the code to work on Excel 2000 and up? Below is the code I am using. Thanks in advance!


    Sub load_csv()
        Dim fStr As String
    
        With Application.FileDialog(msoFileDialogFilePicker)
            .Show
            If .SelectedItems.Count = 0 Then
                MsgBox "Cancel Selected"
                Exit Sub
            End If
            'fStr is the file path and name of the file you selected.
            fStr = .SelectedItems(1)
        End With
    
        With ThisWorkbook.Sheets("Data").QueryTables.Add(Connection:= _
        "TEXT;" & fStr, Destination:=ThisWorkbook.Sheets("Data").Range("$F$6"))
            .Name = "CAPTURE"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = False
            .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 = True
            .TextFileSemicolonDelimiter = False
            .TextFileCommaDelimiter = True
            .TextFileSpaceDelimiter = False
            .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
            .TextFileTrailingMinusNumbers = True
            .Refresh BackgroundQuery = False
    
        End With
    End Sub
    Last edited by Leith Ross; 02-17-2013 at 04:21 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

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