Need help taking certain info from a CSV and putting it into another spreadsheet for 60+ locations.

Occasional Visitor

I am a novice when it comes to Excel. I have been tasked with taking daily store numbers/performance from a report I can download from each store, and putting that data into our spreadsheet. It is time consuming to manually do this. It is for 60+ locations. Is there a macros or formula to help automatically bring this info over?

1 Reply


Is there a formula or macro that knows just which 60+ files to read your data from, which rows to examine, which columns contain the data important to you, and where that data is to be pasted into your company's spreadsheet? Of course not.


If your company is not willing to hire a programmer to create such a macro, prepare to create one yourself. Become familiar with the VBA editor (Alt+F11) and its child windows. Learn how variables are defined (usually with a Dim statement) and what the VBA native data types are (String, Integer, Long, Date, and more); learn what arrays are, and how individual array elements are referenced. Learn how to display a custom message in a dialog (the MsgBox function). Learn how to use text files (the Open, Close, and Line Input statements) and how the Split statement can create an array of strings from one string. Learn what the main Excel-supplied objects are, and how to write VBA code to use their properties and methods, and assign new values to cells. There are plenty of books on Excel VBA; if you don't want to buy one, check with your local library.


My impression is that your new macro (in a macro-enabled workbook) should include a spreadsheet that contains a list of the 60+ filenames. The macro should in turn:

  1. copy the value of a cell in that list into a variable;
  2. determine the fully-qualified file specification, and open that file (issuing a warning message about unavailable data if unsuccessful);
  3. read the necessary row(s);
  4. split the comma-separated values from a line of text (now in a variable) into an array of strings;
  5. assign the relevant values (in specific array entries) into specific cells in the target spreadsheet;
  6. close that file; and
  7. repeat those actions for each non-empty cell in the list.

All of that can be done even with old versions of Excel.


Important note: Test this macro by writing values to a spreadsheet that is not your production-data spreadsheet.  Only after extensive testing, and preferably code review by someone else, should you start modifying the production-data spreadsheet.