+ Reply to Thread
Results 1 to 5 of 5

Referencing file names

  1. #1
    Registered User
    Join Date
    11-07-2015
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    91

    Referencing file names

    Hi all,

    I'm fairly new to VBA and looking for a solution to the following problem.

    I have some code which is pulling data from a closed workbook and pasting into an open, master workbook.

    The reference to the closed workbook is as follows:

    srcPath = masterPath & "\Raw Data\TestDataGSP1.xlsx"

    Instead of using this fixed path, how can i look for any file which contains the string 'GSP' within it.

    Thanks in advance!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,165

    Re: Referencing file names

    This can be done with the built-in Dir function.

    What do you want to do if there is more than one file containing the string "GSP" in the name?

    How are you pulling data from a closed workbook?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    11-07-2015
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    91

    Re: Referencing file names

    Thanks for the advice. I worked it out using the Dir function. I plan to loop through each file found

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,800

    Re: Referencing file names

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,165

    Re: Referencing file names

    Glad you worked it out, but I can take a look at your code if you have any questions.

+ 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. Replies: 3
    Last Post: 03-19-2022, 12:15 PM
  2. Referencing other workbook file names by formula
    By billyshears in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-29-2013, 10:22 AM
  3. Excel 2007 : Referencing File names in Excel...
    By Demtro in forum Excel General
    Replies: 1
    Last Post: 07-25-2011, 02:40 AM
  4. Referencing Changing File Names
    By Dave1674 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-15-2007, 12:19 PM
  5. Referencing Sheet Names
    By Stuart Grant in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 10-04-2005, 11:05 AM
  6. Referencing worksheet names
    By Bernard Liengme in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 09-06-2005, 05:05 PM
  7. [SOLVED] Referencing worksheet names
    By Rich Hayes in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 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