+ Reply to Thread
Results 1 to 6 of 6

Get data from Excel file using query if part of the filename changes regularly.

  1. #1
    Forum Contributor
    Join Date
    06-25-2012
    Location
    U.K
    MS-Off Ver
    Excel 2016
    Posts
    101

    Get data from Excel file using query if part of the filename changes regularly.

    Hi,

    Does anybody know how to use query to get data from another Excel file who's name changes regularly.

    The file is always in the same location, but the filename changes on a daily basis.

    ACTIVE 01022021.xls
    ACTIVE 02022021.xls
    ACTIVE 03022021.xls

    And so on.

    There is only ever one file containing the word ACTIVE, the word ACTIVE gets replaced with ARCHIVED.

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Get data from Excel file using query if part of the filename changes regularly.

    Record your query and then modify the macro. The file name can be created based on current date. e.g.
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    06-25-2012
    Location
    U.K
    MS-Off Ver
    Excel 2016
    Posts
    101

    Re: Get data from Excel file using query if part of the filename changes regularly.

    Hi,

    Sorry but I think you may have misunderstood the question.

    I require using query to retrieve data from another workbook, but the name of the workbook changes regularly.

    Can I change the filename in the advanced editor and use wildcards (*ACTIVE*.xls)

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Get data from Excel file using query if part of the filename changes regularly.

    Misunderstanding would not be the first time for me. I can only guess at what is actually being asked without full details. When seeking help, sometimes you get the best help if you can attach a short example file(s).

    I don't know what advanced editor you are talking about. I think that you are talking about modifying a manually built Query. Using wildcards is not going to solve the problem. Manual queries are limited to the built query. I guess you could manually edit it each time.

    People mean different things for query so the recorded macro needs to come from you or in a simple attached file or the manual query stored in an attached file. It is hard to help someone without exact details.

    I proposed a complete and dynamic solution that actually works. After re-reading post #1, it looks like you need the ddmmyyyy date format. That is easily done.
    MsgBox "ACTIVE " & Format(Date, "ddmmyyyy") & ".xls"

    There are many ways to get data from other Excel files. QueryTables, ADO, Excel4, etc.

  5. #5
    Forum Contributor
    Join Date
    06-25-2012
    Location
    U.K
    MS-Off Ver
    Excel 2016
    Posts
    101

    Re: Get data from Excel file using query if part of the filename changes regularly.

    Hi,

    Here is a screenshot that i hope will explain.

    Attachment 720454

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,605

    Re: Get data from Excel file using query if part of the filename changes regularly.

    I feel that you are talking about Power Query (Get & Transform)
    If so then I believe that you can use the filter on the Name column header to select Text Filter > Contains > type ACTIVE (I believe that it is case sensitive)
    Here is a video showing how to only select files with certain extensions (beginning at 9:42) which may be helpful also.
    https://www.youtube.com/watch?v=_csX8sCzJd0
    By the way selecting Attachment 720454 results in the message: "Invalid Attachment specified. If you followed a valid link, please notify the administrator"
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. [SOLVED] how do i open up a file knowing the first part of the filename in excel using vba
    By BrianTFC in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-22-2019, 03:31 PM
  2. Replies: 3
    Last Post: 07-31-2017, 02:08 PM
  3. VBA Opening a file when only part of filename is known
    By Mastaglio in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-25-2017, 03:21 AM
  4. Importing Data from a regularly updated CLOSED excel workbook
    By sdhutty in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-10-2016, 06:31 AM
  5. Open File in Directory with a Part of Filename as String
    By paesu57 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2014, 06:27 AM
  6. Array of Worksheet Names to be Updated regularly from Web Query
    By Ham Goat in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-12-2013, 09:04 AM
  7. Replies: 2
    Last Post: 09-22-2006, 11:02 AM

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