I have some code which will create and save a new file in to a folder named after the value in cell A1, and also name the file after the value in cell A1 (e.g. C:\Folders\test\test.xlsm, where "test" is the value in A1). This is if the file does not already exist, so I have set this code up as an IF function. If it file already exists, then I want the code simply to open it. My code for that part is here:
When I run this macro for a new file, one is created exactly where I need it and in the correct format. However, when I run the macro again, I receive this error:
"Run-time error '1004':
Sorry, we couldn't find C:\Folders\. Is it possible it was moved, renamed or deleted?"
The way in which I have structured the filename above in the code for opening the file is the same structure I have used for creating a new one. What am I doing wrong here?
Code:
Else
Workbooks.Open Filename:="C:\Folders\" & Range("A1").Text & "\" & Range("A1").Text
When I run this macro for a new file, one is created exactly where I need it and in the correct format. However, when I run the macro again, I receive this error:
"Run-time error '1004':
Sorry, we couldn't find C:\Folders\. Is it possible it was moved, renamed or deleted?"
The way in which I have structured the filename above in the code for opening the file is the same structure I have used for creating a new one. What am I doing wrong here?