How to automatically import data from csv file and append to existing Excel table












0














I have a .csv file and a master excel file. The master file contains a table and I would like to automatically append the data in the .csv file to the existing table. The data has the same headers and column order. I have the folllowing VBA which appends the .csv data to the next row after the table fine, but the data is not part of the table:



Sub Append_CSV_File()

Dim csvFileName As Variant
Dim destCell As Range

Set destCell = Worksheets("Sheet1").Cells(Rows.Count,
"E").End(xlUp).Offset(1) 'Sheet1

csvFileName = Application.GetOpenFilename(FileFilter:="CSV Files
(*.csv),*.csv", Title:="Select a CSV File", MultiSelect:=False)
If csvFileName = False Then Exit Sub

With destCell.Parent.QueryTables.Add(Connection:="TEXT;" & csvFileName,
Destination:=destCell)
.TextFileStartRow = 2
.TextFileParseType = xlDelimited
.TextFileCommaDelimiter = True
.Refresh BackgroundQuery:=False
End With

destCell.Parent.QueryTables(1).Delete

End Sub


There are also columns in the table to the right of the data that calculate a value from the imported data. Is there anyway to automatically have the formulas copied down the column when the new data is appended?










share|improve this question



























    0














    I have a .csv file and a master excel file. The master file contains a table and I would like to automatically append the data in the .csv file to the existing table. The data has the same headers and column order. I have the folllowing VBA which appends the .csv data to the next row after the table fine, but the data is not part of the table:



    Sub Append_CSV_File()

    Dim csvFileName As Variant
    Dim destCell As Range

    Set destCell = Worksheets("Sheet1").Cells(Rows.Count,
    "E").End(xlUp).Offset(1) 'Sheet1

    csvFileName = Application.GetOpenFilename(FileFilter:="CSV Files
    (*.csv),*.csv", Title:="Select a CSV File", MultiSelect:=False)
    If csvFileName = False Then Exit Sub

    With destCell.Parent.QueryTables.Add(Connection:="TEXT;" & csvFileName,
    Destination:=destCell)
    .TextFileStartRow = 2
    .TextFileParseType = xlDelimited
    .TextFileCommaDelimiter = True
    .Refresh BackgroundQuery:=False
    End With

    destCell.Parent.QueryTables(1).Delete

    End Sub


    There are also columns in the table to the right of the data that calculate a value from the imported data. Is there anyway to automatically have the formulas copied down the column when the new data is appended?










    share|improve this question

























      0












      0








      0







      I have a .csv file and a master excel file. The master file contains a table and I would like to automatically append the data in the .csv file to the existing table. The data has the same headers and column order. I have the folllowing VBA which appends the .csv data to the next row after the table fine, but the data is not part of the table:



      Sub Append_CSV_File()

      Dim csvFileName As Variant
      Dim destCell As Range

      Set destCell = Worksheets("Sheet1").Cells(Rows.Count,
      "E").End(xlUp).Offset(1) 'Sheet1

      csvFileName = Application.GetOpenFilename(FileFilter:="CSV Files
      (*.csv),*.csv", Title:="Select a CSV File", MultiSelect:=False)
      If csvFileName = False Then Exit Sub

      With destCell.Parent.QueryTables.Add(Connection:="TEXT;" & csvFileName,
      Destination:=destCell)
      .TextFileStartRow = 2
      .TextFileParseType = xlDelimited
      .TextFileCommaDelimiter = True
      .Refresh BackgroundQuery:=False
      End With

      destCell.Parent.QueryTables(1).Delete

      End Sub


      There are also columns in the table to the right of the data that calculate a value from the imported data. Is there anyway to automatically have the formulas copied down the column when the new data is appended?










      share|improve this question













      I have a .csv file and a master excel file. The master file contains a table and I would like to automatically append the data in the .csv file to the existing table. The data has the same headers and column order. I have the folllowing VBA which appends the .csv data to the next row after the table fine, but the data is not part of the table:



      Sub Append_CSV_File()

      Dim csvFileName As Variant
      Dim destCell As Range

      Set destCell = Worksheets("Sheet1").Cells(Rows.Count,
      "E").End(xlUp).Offset(1) 'Sheet1

      csvFileName = Application.GetOpenFilename(FileFilter:="CSV Files
      (*.csv),*.csv", Title:="Select a CSV File", MultiSelect:=False)
      If csvFileName = False Then Exit Sub

      With destCell.Parent.QueryTables.Add(Connection:="TEXT;" & csvFileName,
      Destination:=destCell)
      .TextFileStartRow = 2
      .TextFileParseType = xlDelimited
      .TextFileCommaDelimiter = True
      .Refresh BackgroundQuery:=False
      End With

      destCell.Parent.QueryTables(1).Delete

      End Sub


      There are also columns in the table to the right of the data that calculate a value from the imported data. Is there anyway to automatically have the formulas copied down the column when the new data is appended?







      microsoft-excel vba csv microsoft-excel-2016 visual-basic






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 6 '17 at 14:42









      cmccarra

      614




      614






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I had the same issue, and wanted to append several (16 to be precise) csv files in one listing. The Array I used is static and there are better ways of coding this, but I needed to collect specific files from a number of csv files that are within the folder location.



          I found your code interesting, and updated the code that I had put together from other sources to get a set of code working.



          Thanks for sharing your code, as you will see I've used an element of your code to find the next blank row to append to.



          See below code example, you will need to add the filenames, and file directory path, and update the xFiles array to match the number of files that you want to import and append:



          Sub LoadDelimitedFiles()

          Dim xStrPath As String
          Dim xFile As String
          Dim xCount As Long
          Dim xFiles(15) As String
          Dim destCell As Range

          On Error GoTo ErrHandler
          'added an update to the code to select the individual file names needed from server within a folder

          'PathName of Folder Location
          xStrPath = "<Insert Folder Location>"

          'Name the Array with the CSV files name for file Content

          xFiles(0) = "<Filename1>"
          xFiles(1) = "<Filename2>"
          xFiles(2) = "<Filename3>"
          xFiles(3) = "<Filename4>"
          xFiles(4) = "<Filename5>"
          xFiles(5) = "<Filename6>"
          xFiles(6) = "<Filename7>"
          xFiles(7) = "<Filename8>"
          xFiles(8) = "<Filename9>"
          xFiles(9) = "<Filename10>"
          xFiles(10) = "<Filename11>"
          xFiles(11) = "<Filename12>"
          xFiles(12) = "<Filename13>"
          xFiles(13) = "<Filename14>"
          xFiles(14) = "<Filename15>"
          xFiles(15) = "<Filename16>"

          xCount = 0

          If xStrPath = "" Then Exit Sub
          Application.ScreenUpdating = False

          'Clear Existing Sheet Data
          Columns("A:I").Select
          Selection.Delete Shift:=xlToLeft
          Range("A1").Select

          'Set the 1st Filename
          xFile = Dir(xStrPath & xFiles(xCount) & ".csv")

          'destCell contains the location of the next cell to append the next csv file data to
          Set destCell = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1)

          Do While xCount <> 16
          xFile = Dir(xStrPath & xFiles(xCount) & ".csv")
          With ActiveSheet.QueryTables.Add(Connection:="TEXT;" _
          & xStrPath & xFile, Destination:=destCell)
          .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
          .TextFileConsecutiveDelimiter = False
          .TextFileTabDelimiter = False
          .TextFileSemicolonDelimiter = False
          .TextFileCommaDelimiter = True
          .TextFileSpaceDelimiter = False
          .TextFileOtherDelimiter = False
          .TextFileColumnDataTypes = Array(1, 1, 1)
          .TextFileTrailingMinusNumbers = True
          .Refresh BackgroundQuery:=False

          Set destCell = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1)
          xCount = xCount + 1
          End With

          Loop
          'Remove the Blank Top row
          Rows("1:1").Select
          Selection.Delete Shift:=xlUp
          Range("A1").Select

          'Update the screen to show the contents appended csv file data
          Application.ScreenUpdating = True
          Exit Sub
          ErrHandler:
          MsgBox "no files found", , "Error Message"
          End Sub





          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1247921%2fhow-to-automatically-import-data-from-csv-file-and-append-to-existing-excel-tabl%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I had the same issue, and wanted to append several (16 to be precise) csv files in one listing. The Array I used is static and there are better ways of coding this, but I needed to collect specific files from a number of csv files that are within the folder location.



            I found your code interesting, and updated the code that I had put together from other sources to get a set of code working.



            Thanks for sharing your code, as you will see I've used an element of your code to find the next blank row to append to.



            See below code example, you will need to add the filenames, and file directory path, and update the xFiles array to match the number of files that you want to import and append:



            Sub LoadDelimitedFiles()

            Dim xStrPath As String
            Dim xFile As String
            Dim xCount As Long
            Dim xFiles(15) As String
            Dim destCell As Range

            On Error GoTo ErrHandler
            'added an update to the code to select the individual file names needed from server within a folder

            'PathName of Folder Location
            xStrPath = "<Insert Folder Location>"

            'Name the Array with the CSV files name for file Content

            xFiles(0) = "<Filename1>"
            xFiles(1) = "<Filename2>"
            xFiles(2) = "<Filename3>"
            xFiles(3) = "<Filename4>"
            xFiles(4) = "<Filename5>"
            xFiles(5) = "<Filename6>"
            xFiles(6) = "<Filename7>"
            xFiles(7) = "<Filename8>"
            xFiles(8) = "<Filename9>"
            xFiles(9) = "<Filename10>"
            xFiles(10) = "<Filename11>"
            xFiles(11) = "<Filename12>"
            xFiles(12) = "<Filename13>"
            xFiles(13) = "<Filename14>"
            xFiles(14) = "<Filename15>"
            xFiles(15) = "<Filename16>"

            xCount = 0

            If xStrPath = "" Then Exit Sub
            Application.ScreenUpdating = False

            'Clear Existing Sheet Data
            Columns("A:I").Select
            Selection.Delete Shift:=xlToLeft
            Range("A1").Select

            'Set the 1st Filename
            xFile = Dir(xStrPath & xFiles(xCount) & ".csv")

            'destCell contains the location of the next cell to append the next csv file data to
            Set destCell = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1)

            Do While xCount <> 16
            xFile = Dir(xStrPath & xFiles(xCount) & ".csv")
            With ActiveSheet.QueryTables.Add(Connection:="TEXT;" _
            & xStrPath & xFile, Destination:=destCell)
            .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
            .TextFileConsecutiveDelimiter = False
            .TextFileTabDelimiter = False
            .TextFileSemicolonDelimiter = False
            .TextFileCommaDelimiter = True
            .TextFileSpaceDelimiter = False
            .TextFileOtherDelimiter = False
            .TextFileColumnDataTypes = Array(1, 1, 1)
            .TextFileTrailingMinusNumbers = True
            .Refresh BackgroundQuery:=False

            Set destCell = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1)
            xCount = xCount + 1
            End With

            Loop
            'Remove the Blank Top row
            Rows("1:1").Select
            Selection.Delete Shift:=xlUp
            Range("A1").Select

            'Update the screen to show the contents appended csv file data
            Application.ScreenUpdating = True
            Exit Sub
            ErrHandler:
            MsgBox "no files found", , "Error Message"
            End Sub





            share|improve this answer


























              0














              I had the same issue, and wanted to append several (16 to be precise) csv files in one listing. The Array I used is static and there are better ways of coding this, but I needed to collect specific files from a number of csv files that are within the folder location.



              I found your code interesting, and updated the code that I had put together from other sources to get a set of code working.



              Thanks for sharing your code, as you will see I've used an element of your code to find the next blank row to append to.



              See below code example, you will need to add the filenames, and file directory path, and update the xFiles array to match the number of files that you want to import and append:



              Sub LoadDelimitedFiles()

              Dim xStrPath As String
              Dim xFile As String
              Dim xCount As Long
              Dim xFiles(15) As String
              Dim destCell As Range

              On Error GoTo ErrHandler
              'added an update to the code to select the individual file names needed from server within a folder

              'PathName of Folder Location
              xStrPath = "<Insert Folder Location>"

              'Name the Array with the CSV files name for file Content

              xFiles(0) = "<Filename1>"
              xFiles(1) = "<Filename2>"
              xFiles(2) = "<Filename3>"
              xFiles(3) = "<Filename4>"
              xFiles(4) = "<Filename5>"
              xFiles(5) = "<Filename6>"
              xFiles(6) = "<Filename7>"
              xFiles(7) = "<Filename8>"
              xFiles(8) = "<Filename9>"
              xFiles(9) = "<Filename10>"
              xFiles(10) = "<Filename11>"
              xFiles(11) = "<Filename12>"
              xFiles(12) = "<Filename13>"
              xFiles(13) = "<Filename14>"
              xFiles(14) = "<Filename15>"
              xFiles(15) = "<Filename16>"

              xCount = 0

              If xStrPath = "" Then Exit Sub
              Application.ScreenUpdating = False

              'Clear Existing Sheet Data
              Columns("A:I").Select
              Selection.Delete Shift:=xlToLeft
              Range("A1").Select

              'Set the 1st Filename
              xFile = Dir(xStrPath & xFiles(xCount) & ".csv")

              'destCell contains the location of the next cell to append the next csv file data to
              Set destCell = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1)

              Do While xCount <> 16
              xFile = Dir(xStrPath & xFiles(xCount) & ".csv")
              With ActiveSheet.QueryTables.Add(Connection:="TEXT;" _
              & xStrPath & xFile, Destination:=destCell)
              .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
              .TextFileConsecutiveDelimiter = False
              .TextFileTabDelimiter = False
              .TextFileSemicolonDelimiter = False
              .TextFileCommaDelimiter = True
              .TextFileSpaceDelimiter = False
              .TextFileOtherDelimiter = False
              .TextFileColumnDataTypes = Array(1, 1, 1)
              .TextFileTrailingMinusNumbers = True
              .Refresh BackgroundQuery:=False

              Set destCell = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1)
              xCount = xCount + 1
              End With

              Loop
              'Remove the Blank Top row
              Rows("1:1").Select
              Selection.Delete Shift:=xlUp
              Range("A1").Select

              'Update the screen to show the contents appended csv file data
              Application.ScreenUpdating = True
              Exit Sub
              ErrHandler:
              MsgBox "no files found", , "Error Message"
              End Sub





              share|improve this answer
























                0












                0








                0






                I had the same issue, and wanted to append several (16 to be precise) csv files in one listing. The Array I used is static and there are better ways of coding this, but I needed to collect specific files from a number of csv files that are within the folder location.



                I found your code interesting, and updated the code that I had put together from other sources to get a set of code working.



                Thanks for sharing your code, as you will see I've used an element of your code to find the next blank row to append to.



                See below code example, you will need to add the filenames, and file directory path, and update the xFiles array to match the number of files that you want to import and append:



                Sub LoadDelimitedFiles()

                Dim xStrPath As String
                Dim xFile As String
                Dim xCount As Long
                Dim xFiles(15) As String
                Dim destCell As Range

                On Error GoTo ErrHandler
                'added an update to the code to select the individual file names needed from server within a folder

                'PathName of Folder Location
                xStrPath = "<Insert Folder Location>"

                'Name the Array with the CSV files name for file Content

                xFiles(0) = "<Filename1>"
                xFiles(1) = "<Filename2>"
                xFiles(2) = "<Filename3>"
                xFiles(3) = "<Filename4>"
                xFiles(4) = "<Filename5>"
                xFiles(5) = "<Filename6>"
                xFiles(6) = "<Filename7>"
                xFiles(7) = "<Filename8>"
                xFiles(8) = "<Filename9>"
                xFiles(9) = "<Filename10>"
                xFiles(10) = "<Filename11>"
                xFiles(11) = "<Filename12>"
                xFiles(12) = "<Filename13>"
                xFiles(13) = "<Filename14>"
                xFiles(14) = "<Filename15>"
                xFiles(15) = "<Filename16>"

                xCount = 0

                If xStrPath = "" Then Exit Sub
                Application.ScreenUpdating = False

                'Clear Existing Sheet Data
                Columns("A:I").Select
                Selection.Delete Shift:=xlToLeft
                Range("A1").Select

                'Set the 1st Filename
                xFile = Dir(xStrPath & xFiles(xCount) & ".csv")

                'destCell contains the location of the next cell to append the next csv file data to
                Set destCell = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1)

                Do While xCount <> 16
                xFile = Dir(xStrPath & xFiles(xCount) & ".csv")
                With ActiveSheet.QueryTables.Add(Connection:="TEXT;" _
                & xStrPath & xFile, Destination:=destCell)
                .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
                .TextFileConsecutiveDelimiter = False
                .TextFileTabDelimiter = False
                .TextFileSemicolonDelimiter = False
                .TextFileCommaDelimiter = True
                .TextFileSpaceDelimiter = False
                .TextFileOtherDelimiter = False
                .TextFileColumnDataTypes = Array(1, 1, 1)
                .TextFileTrailingMinusNumbers = True
                .Refresh BackgroundQuery:=False

                Set destCell = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1)
                xCount = xCount + 1
                End With

                Loop
                'Remove the Blank Top row
                Rows("1:1").Select
                Selection.Delete Shift:=xlUp
                Range("A1").Select

                'Update the screen to show the contents appended csv file data
                Application.ScreenUpdating = True
                Exit Sub
                ErrHandler:
                MsgBox "no files found", , "Error Message"
                End Sub





                share|improve this answer












                I had the same issue, and wanted to append several (16 to be precise) csv files in one listing. The Array I used is static and there are better ways of coding this, but I needed to collect specific files from a number of csv files that are within the folder location.



                I found your code interesting, and updated the code that I had put together from other sources to get a set of code working.



                Thanks for sharing your code, as you will see I've used an element of your code to find the next blank row to append to.



                See below code example, you will need to add the filenames, and file directory path, and update the xFiles array to match the number of files that you want to import and append:



                Sub LoadDelimitedFiles()

                Dim xStrPath As String
                Dim xFile As String
                Dim xCount As Long
                Dim xFiles(15) As String
                Dim destCell As Range

                On Error GoTo ErrHandler
                'added an update to the code to select the individual file names needed from server within a folder

                'PathName of Folder Location
                xStrPath = "<Insert Folder Location>"

                'Name the Array with the CSV files name for file Content

                xFiles(0) = "<Filename1>"
                xFiles(1) = "<Filename2>"
                xFiles(2) = "<Filename3>"
                xFiles(3) = "<Filename4>"
                xFiles(4) = "<Filename5>"
                xFiles(5) = "<Filename6>"
                xFiles(6) = "<Filename7>"
                xFiles(7) = "<Filename8>"
                xFiles(8) = "<Filename9>"
                xFiles(9) = "<Filename10>"
                xFiles(10) = "<Filename11>"
                xFiles(11) = "<Filename12>"
                xFiles(12) = "<Filename13>"
                xFiles(13) = "<Filename14>"
                xFiles(14) = "<Filename15>"
                xFiles(15) = "<Filename16>"

                xCount = 0

                If xStrPath = "" Then Exit Sub
                Application.ScreenUpdating = False

                'Clear Existing Sheet Data
                Columns("A:I").Select
                Selection.Delete Shift:=xlToLeft
                Range("A1").Select

                'Set the 1st Filename
                xFile = Dir(xStrPath & xFiles(xCount) & ".csv")

                'destCell contains the location of the next cell to append the next csv file data to
                Set destCell = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1)

                Do While xCount <> 16
                xFile = Dir(xStrPath & xFiles(xCount) & ".csv")
                With ActiveSheet.QueryTables.Add(Connection:="TEXT;" _
                & xStrPath & xFile, Destination:=destCell)
                .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
                .TextFileConsecutiveDelimiter = False
                .TextFileTabDelimiter = False
                .TextFileSemicolonDelimiter = False
                .TextFileCommaDelimiter = True
                .TextFileSpaceDelimiter = False
                .TextFileOtherDelimiter = False
                .TextFileColumnDataTypes = Array(1, 1, 1)
                .TextFileTrailingMinusNumbers = True
                .Refresh BackgroundQuery:=False

                Set destCell = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Offset(1)
                xCount = xCount + 1
                End With

                Loop
                'Remove the Blank Top row
                Rows("1:1").Select
                Selection.Delete Shift:=xlUp
                Range("A1").Select

                'Update the screen to show the contents appended csv file data
                Application.ScreenUpdating = True
                Exit Sub
                ErrHandler:
                MsgBox "no files found", , "Error Message"
                End Sub






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 28 at 14:32









                Russ

                1




                1






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1247921%2fhow-to-automatically-import-data-from-csv-file-and-append-to-existing-excel-tabl%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Mouse cursor on multiple screens with different PPI

                    Agildo Ribeiro

                    Sometime when accessing a menu: “Ubuntu 16.04 has experienced an internal error”