+ Reply to Thread
Results 1 to 5 of 5

Extracting data from new files?

Hybrid View

  1. #1
    Registered User
    Join Date
    01-25-2010
    Location
    america
    MS-Off Ver
    Excel 2007
    Posts
    13

    Extracting data from new files?

    I would like to take data from 4 different files (each in their own respective directory) and put them into one excel file.

    This needs to be done each day. There is 1 file per directory and it gets created each day. So each of these 4 file has a time stamp on it. Ex: LAB XXX-median-May-18-10.asc

    Is it possible to have a new file updated with all of the data compiled from each of these four files into one new spreadsheet?

    How would I go about making a macro for that?

    Thank you in advance!!!!!!!!! I am very patient and I am not a programmer, but I am good at listening and am relatively computer literate.

  2. #2
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: Extracting data from new files?

    OK, I was also not a programmer (not in VBA anyway) about 3 months back, but I was able to write a fairly complex macro, running into thousands of lines of code, by breaking down my project into tasks.

    I started by googling "writing my first excel macro", and kept modifying that first macro per my requirements.

    If you are willing to learn and write your own macro, folks in this forum can help you.

    Here are the steps for you to start researching and get started:-
    1. How to write a macro to open a file
    a) given its name and directory location, or
    b) by calling "Open File" method

    2. How to write a macro to copy sheets from one file to another

    You can start searching solution (code) for these steps - one at a time - and writing your own code. We are always here to help if you get stuck.

    hth
    All the best
    Ajay

  3. #3
    Registered User
    Join Date
    01-25-2010
    Location
    america
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Extracting data from new files?

    okay, thank you. i will take a look at some of this stuff over the next few days.

  4. #4
    Registered User
    Join Date
    01-25-2010
    Location
    america
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Extracting data from new files?

    is there a specific command to open a file if it has a date in the file name?
    ex:
    this morning this file was created
    LAB 221-median-May-19-10.asc

    tomorrow this will be created
    LAB 221-median-May-20-10.asc

    is there a command so that my script will retrieve the data from only the file with today's date?

    thanks!

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

    Re: Extracting data from new files?

    To construct a string using fixed text and todays date:

    Dim fName as String
    
    fName = "LAB 221-median-" & Format(Date, "MMM-DD-YY") & ".asc"
    Just use the fName variable after that in place of your current file name open code. The example above assumes the month is always 3 letters and the day is always 2 digits, like Feb-01-10.asc
    _________________
    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!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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