+ Reply to Thread
Results 1 to 3 of 3

Excel Macro - Importing CSV files below one another in Spreadsheet

  1. #1
    Registered User
    Join Date
    10-24-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2013
    Posts
    87

    Excel Macro - Importing CSV files below one another in Spreadsheet

    Hello Guys,

    I'll start off with saying I have rather limited knowledge with Excel Macro's and VB programming. I am also using Excel 2010.

    What I intended to do is develop a macro that that will load a CSV file into my Excel Spreadsheet below the existing data I already have. I will be uploading a CSV file into it every month. I developed a macro that adds a CSV file into the spreadsheet, However, this will only properly work once. If I run the macro again, instead of putting the contents of the CSV file below the existing data (which is all in columns A,B and C), it shifts all the data over.

    The problem with this is I need all the data to be in columns A, B, C because I have created formulas to automatically generate a graph.

    So basically my question is, How do I import a CSV file to be added below my existing data in columns A, B and C?


    Here is a picture of my Excel spreadsheet.Excel Help.jpg. All data should be in columns A, B and C. I have two different macro buttons. When I click the "step 2" macro button it will load the CSV file into the spreadsheet, and the formulas will generate data for the graph.

    Here is a picture of the problem I experience when I run the Macro more than once. Excel Help 2.jpg. In this picture you can see how all the data gets shifted, instead of putting the new data below the existing data.

    Here is the macro that I already have
    Please Login or Register  to view this content.
    I will greatly appreciate any help. I apologize if this is a rather simple task as well. Thanks guys

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Excel Macro - Importing CSV files below one another in Spreadsheet

    Your active query will put the data in the same place every time. To import multiples, you really need to import to one sheet, then copy to another, repeat ad nauseum.


    'CSVs To One Sheet (Stacked)
    Here's a macro for importing all CSV files in a folder into a single Excel sheet, each CSV filename will be listed on the sheet next to the data that it came from.


    CSVs to 1 Sheet - Part 1



    See if you can adapt that since this is already designed for what you're trying to do.
    Last edited by JBeaucaire; 12-27-2019 at 10:40 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    10-24-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2013
    Posts
    87

    Re: Excel Macro - Importing CSV files below one another in Spreadsheet

    Thanks a lot for the response. By looking at the code this looks like it will work great. I will update the post if it works successfully and mark it as solved. Thanks again

+ Reply to Thread

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