• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Open Folder from Excel Sheet VBA

BarraPippo

New Member
Hello all,

i need help with a VBA code. Dont know what im doing wrong

I have an excel sheet and would like a button that when clicked it opens a specific folder, named as the excel sheet i'm clicking the button from

I have a sheet, name 085 - I click the button, the macro starts and it opens a folder in a specific directory named 085
The number 085 which names the sheet is from the Range(Q16)

This is where i am so far. It only opens the MainDesktop although i already have a subfolder in the Desktop named 085

>>> use code - tags <<<
Code:
Sub Open_Folder()
    Const MainFolder As String = "C:\Users\filip\Desktop"
    Dim Foldername As String, MyFolder As String
    MyFolder = ActiveSheet.Range("Q16")
    Foldername = Dir(MainFolder & MyFolder & "*", vbDirectory)   
    Shell "C:\WINDOWS\explorer.exe """ & MainFolder & Foldername & """", vbNormalFocus   
End Sub

Thanks in advance
 
No, cell Q16 is 85

i leave you the sheet im talking about so you can have a better understanding at what im doing
 

Attachments

  • Test.xlsm
    88.1 KB · Views: 2
You skipped ... verified?
Your MainFolder & MyFolder is C:\Users\filip\Desktop85
Do You have somewhere folder Desktop85?
... that's why I asked - what do You should have between MainFolder and MyFolder? ... a pathseparator.
Your I already have a subfolder in the Desktop named 085
... 085 is different than 85 which You have in cell Q16 ... or how?
 
i tried naming my folder both 085 and 85. It doesnt changed

However, i dont have a folder named Desktop85.. just 85

Is that the problem? how can i fix it?
 
As asked ... as written ...
... that's why I asked - what do You should have between MainFolder and MyFolder? ... a pathseparator.
 
Back
Top