MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Oh-My, now this is a problem

Posted by Michael on January 17, 2002 8:24 AM

I have a macro that searches a folder and returns the names to a range of cells that I have a list box attached to. However when I try and execute the serch a second time in a different directory, the same result are given as the first search.

I set the directory as follows

ChDrive "X:\"
ChDir "X:\MaryYoung\ProcessCost\NC"

For the second search I am trying to change the Directory as Follows

ChDrive "X:\"
ChDir "X:\MaryYoung\LBSREC\NC"

Can anybody shed some light?

Posted by Damon Ostrander on January 17, 2002 9:19 AM

Re: Oh-My...

Hi Michael,

You didn't mention what method you were using for searching the folder. If you are using the Dir() function, the ChDir should work. If you are using the FileSearch object of Excel, you need to reset the LookIn property of the FileSearch object with the new path.


Posted by Michael on January 17, 2002 10:27 AM

Thanks, resetting the Lookin worked great. I appreciate it.