I ran across Ken's code that will search for a folder. It works great , but i am curious if it could be adjusted a little. Currently the code looks for a folder entered into the code. In the code below it loks to see if C:\Template exists. I bad need to be able to enter text or data into say cell K10 and the code will look for a folder that contains any part of the data or text entered into this cell.
Example:
I will need code to start at this base folder. N:\Quotes
we will say i have a subfolder named BR549. FULL PATH N:\Quotes\BR549
i would like to be able to enter BR5 IN CELL K10 AND THE CODE will start at N:\Quotes and look for and list all folders that start with BR5.
Example:
I will need code to start at this base folder. N:\Quotes
we will say i have a subfolder named BR549. FULL PATH N:\Quotes\BR549
i would like to be able to enter BR5 IN CELL K10 AND THE CODE will start at N:\Quotes and look for and list all folders that start with BR5.
Code:
Public Function FileFolderExists(strFullPath As String) As Boolean
'Author : Ken Puls ([URL="http://www.excelguru.ca"]www.excelguru.ca[/URL])
'Macro Purpose: Check if a file or folder exists
On Error GoTo EarlyExit
If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True
EarlyExit:
On Error GoTo 0
End Function
Public Sub TestFolderExistence()
'Author : Ken Puls ([URL="http://www.excelguru.ca"]www.excelguru.ca[/URL])
'Macro Purpose: Test if directory exists
If FileFolderExists("C:\Template") Then
MsgBox "Folder exists!"
Else
MsgBox "Folder does not exist!"
End If
End Sub