Home > Mobile >  Opening subfolder with variable name
Opening subfolder with variable name

Time:07-13

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?

CodePudding user response:

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

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

CodePudding user response:

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
  • Related