ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find Correct Subdirectory (https://www.excelbanter.com/excel-programming/316877-find-correct-subdirectory.html)

Stratuser

Find Correct Subdirectory
 
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"?

Don Guillett[_4_]

Find Correct Subdirectory
 
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

--
Don Guillett
SalesAid Software

"Stratuser" wrote in message
...
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"?





All times are GMT +1. The time now is 11:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com