+ Reply to Thread
Results 1 to 6 of 6

Importing Multiple Files into one spreadsheet

Hybrid View

  1. #1
    Registered User
    Join Date
    05-06-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    23

    Importing Multiple Files into one spreadsheet

    Hey guys,

    So I have to import 300 files or so to update a price sheet so we can graph historical prices for something. I was hoping you could help me get the correct VBA/macro to import a folder full of the files that currently contain the old prices, and import a specific column/data from each file and have it transfer to a new sheet. Please let me know if this is possible! I've attached a dumbed down format of what one of the files I'd be extracting the prices from.

    Any help would be greatly appreciated. Don't really know what I'll do if I can't get this to work hah.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    05-06-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    23

    Angry Re: Importing Multiple Files into one spreadsheet

    I tried something along the lines of this, but haven't found any success.

    Option Explicit

    Sub ImportCSVsWithReference()
    'Author: Jerry Beaucaire
    'Date: 11/3/2011
    'Summary: Import all CSV files from a folder into a single sheet
    ' adding a field in row 1 for listing the CSV filenames

    Dim wbCSV As Workbook
    Dim wsMstr As Worksheet: Set wsMstr = ThisWorkbook.Sheets("MasterCSV")
    Dim fPath As String: fPath = "H:\Renewable" 'path to CSV files, include the final \
    Dim fCSV As String
    Dim NextCol As Long

    If MsgBox("Clear the existing MasterCSV sheet before importing?", _
    vbYesNo, "Clear?") = vbYes Then
    wsMstr.UsedRange.Clear
    NextCol = 1
    Else
    NextCol = wsMstr.Cells(3, Columns.Count).End(xlToLeft).Column + 1
    End If

    Application.ScreenUpdating = False 'speed up macro

    fCSV = Dir(fPath & "*.csv") 'start the CSV file listing

    Do While Len(fCSV) > 0
    'open a CSV file
    Set wbCSV = Workbooks.Open(fPath & fCSV)
    'insert row 1 and add CSV name
    Rows(1).Insert xlShiftDown
    Range("A1") = ActiveSheet.Name
    'copy date into master sheet and close source file
    ActiveSheet.UsedRange.Copy wsMstr.Cells(1, NextCol)
    wbCSV.Close False
    'ready next CSV
    fCSV = Dir
    NextCol = wsMstr.Cells(3, Columns.Count).End(xlToLeft).Column + 1
    Loop

    Application.ScreenUpdating = True
    End Sub


    If there is an easier way to handle this, please let me know.

  3. #3
    Registered User
    Join Date
    05-06-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    23

    Re: Importing Multiple Files into one spreadsheet

    bump bump

    another day, same problem

  4. #4
    Registered User
    Join Date
    05-06-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    23

    Re: Importing Multiple Files into one spreadsheet

    anything? anything that would make the process easier

  5. #5
    Registered User
    Join Date
    05-06-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    23

    Re: Importing Multiple Files into one spreadsheet

    still working on this

  6. #6
    Registered User
    Join Date
    05-06-2015
    Location
    NYC
    MS-Off Ver
    2010
    Posts
    23

    Re: Importing Multiple Files into one spreadsheet

    if anyone can help out or give me any direction on this, it would be appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Importing Multiple individual txt files into one single spreadsheet using 2003 Excel
    By keige123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-22-2013, 10:29 PM
  2. [SOLVED] Excel Macro - Importing CSV files below one another in Spreadsheet
    By foxy_420 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-01-2012, 01:33 PM
  3. [SOLVED] Macro for importing multiple TAB files into one spreadsheet
    By Delta in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-04-2012, 05:48 AM
  4. importing multiple text files into a single excel spreadsheet
    By Strayrog in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-15-2010, 11:52 PM
  5. [SOLVED] Importing multiple files into spreadsheet
    By ghs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2006, 04:35 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