Hi Everyone,
I keep receiving the run-time error '76' saying path is not found & I can not understand why. I have tried using as many sites as possible to understand but it doesn't make sense.
Background:
I am writing the code in a userform & the individual who runs the macro has the option to change the file path (using combo boxes for the correct year & quarter which it is ran). I use an IF statement to check whether the directory already exists (majority of the time it doesn't) and then using MkDir to create my file path, which is the point it fails at. I have highlighted in red the point it fails. Please see short code below:
Dim filepath As String
Dim folder As String
filepath = Me.tb_folderpath & Me.cb_year & "\" & Me.cb_Qtr & "\" & CoCo
folder = Dir(filepath, vbDirectory)
Trim (filepath)
MsgBox (filepath)
'This checks a folder path, is it doesnt exist it creates it
If Len(Dir(filepath, vbDirectory)) = 0 Then
MkDir filepath
End If
Display More
The MkDir filepath is where it fails. Does anyone have any suggestions to why it may be failing? I will put the whole code below to help put somethings into context for you. (the me.tb_folderpath etc are the combo & text boxes where the individual can identify which paths they want the files to be saved in). If anyone would like more information/additional code please let me know.
I have tested the filepath & it returns exactly what I want it too, so I am unsure how to resolve this issue.
Thanks,
Mel