Find Correct Subdirectory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to change the current subdirectory to the one that is one level higher
and contains the string "Russell". I know how to change the directory to
one level higher (ChDir ".."). How can I loop through the subdirectories to
find the one containing the word "Russell"?
 
Let us know if this helps.

Sub finddir()
Dim mypath, myname
mypath = "c:\yourfolder\"
myname = Dir(mypath, vbDirectory)
Do While myname <> ""
If myname = "yourname" Then ChDir "c:\personal\yourname": Exit Sub
myname = Dir
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top