-1

I would like to find an efficient way to open a subfolder with a variable name which I enter in Excel.

For example, I would like to enter the subfolder name "AB 123456" in a cell in Excel and then it should search the network folder "J:\Projects" which has many subfolders which in its turn again has subfolders. These subfolders again have subfolders, etc.

Of course I could go to the subfolder by always clicking, but it would be more efficient if it opens when entering the subfolder's name.

Any suggestions on how to do this?

2 Answers2

0

Something like this, but change file path to var = Range("A1").Value

Don't know how to search for sub-subfolders tho

antca230
  • 56
  • 4
0

Try this.

Sub Open_Folder()

    Dim FolderPath As String
    Dim FolderName As String
    Dim FullPath As String
    
    FolderName = Range("A1").Value

    FolderPath = "J:\Projects\"
    FullPath = FolderPath & FolderName
    
    Call Shell("explorer.exe" & " " & FullPath, vbNormalFocus)
    
End Sub
Patrick
  • 212
  • 2
  • 11
  • The folder in question could be a subfolder of another folder so recursive search is required to locate the folder before attempting to open it. – Kostas K. Jul 13 '22 at 10:20