+ Reply to Thread
Results 1 to 7 of 7

Accessing files with specific name to provide a solution

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-11-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    108

    Question Accessing files with specific name to provide a solution

    Hi. I have a column full of names. So for example


    Dogs
    Alsatian
    Alsatian_Young
    Alsatian_Old
    Corgi
    Poodle
    Labrador
    Labrador_Black
    Labrador_White

    I also have a folder with file names as follows

    Alsatian, Corgi, Poodle, Labrador

    I need to retrieve some information from these files and it will go in the adjacent column. My problem is that in my list I have some Dog names which have more specific descriptions so for example the Alsatian_Young, but the thing to note is that the information for Alsation_Young must come from the "Alsatian.xls" file in the same way that the Labrador_White information exists in the "Labrador.xls" file. Therefore it is not as straightforward as just looping through all the files in the folder because I have these additional names in the columns that sometimes have to reference the same file.

    Any ideas what a working solution could be?

    Thanks for your help.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Accessing files with specific name to provide a solution

    Is it possible for you to have a separate column which will state the file names from where the data should come from? Then the looping can happen easily.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    04-11-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    108

    Question Re: Accessing files with specific name to provide a solution

    Yes. I could see how that might work. I was thinking that since the file name is always just the Dog name, eg "Labrador", then I could initially do a comparision for each cell in the Dog column with every other cell below it, given the column below starting in A1

    Labrador
    Labrador_White
    Labrador_Black

    I could do a match so that if any of the cells below A1 contained the word labrador it would store "Labrador" in the adjacent cell, B2 and B3 would register "Labrador" which could be used to reference the file name.

    What function can check if a cell contains a given word?

    Also how can I tell it to open a particular file with the filename given by a variable? So if I search the contents in B2 and find "Labrador" and store that in a variable "Name" then I want to search for a file called "Name.xls".

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Accessing files with specific name to provide a solution

    Is there a particular format? For e.g entries could be either "Labrador" or "Labrador_white"? What i mean is, if the entries with additional details (white in this case) and if they are separated by one identifier only ("_" in this case) then, that portion can be automated easily, without the extra column.

  5. #5
    Forum Contributor
    Join Date
    04-11-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Accessing files with specific name to provide a solution

    Well sometimes they have up to a maximum of two identifiers. So worst case scenario there would be

    Labrador_White_Young

    but otherwise nothing different to that.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Accessing files with specific name to provide a solution

    So if we are looking for "Labrador", we will find either "Labrador" or "Labrador_" right?

  7. #7
    Forum Contributor
    Join Date
    04-11-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Accessing files with specific name to provide a solution

    Yes that's right.

+ 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