+ Reply to Thread
Results 1 to 4 of 4

Parent Directory??

  1. #1
    Registered User
    Join Date
    09-23-2008
    Location
    England
    Posts
    14

    Parent Directory??

    Hi All

    I am trying to extract from a directory string the Parent folder one step back from the file location using VBA.

    For example:

    C:\Parent 1\Parent 2\Parent 3\Parent 4\file.xls

    I would like to return the value 'Parent 4'.

    Unfortunately the number of sub directory will not always be 4 as in the example above.

    Any help would be gratefully received as I've been searching and trying different things all day.

    Thanks in advance

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Parent Directory??

    Use the Split function and get the next to last element.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Parent Directory??

    Hi,

    hope this helps.

    Please Login or Register  to view this content.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  4. #4
    Registered User
    Join Date
    09-23-2008
    Location
    England
    Posts
    14

    Re: Parent Directory??

    Thats amazing, thank you shg for pointing me in the right direction and thank you xlbiznes for your code.

    Works perfect.

    Thank you

+ 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