Open file with file name from cell

  • Thread starter Thread starter Thore
  • Start date Start date
T

Thore

Hi all,

here is a real beginner question: I have got a named cell
with path & xls-file name in it. What code do I need to
open that specific file with a macro?

Closely related to that topic: Do I always need the entire
path or is it somehow possible to use a "relative path"
from the location of the file where the macro is stored in?
Finally, how do I remove a cell name so that the cell is
again referred to as A1 or whatever? Simply deleting the
name from the Name Box does not work...

Thanks in advance,
Thore
 
Code:
--------------------

Dim MyPath As String
Dim MyFile As String
'-----------------------
MyPath = ThisWorkbook.Path & "MyFolder\"
MyFile = MyPath & ActiveSheet.Range("MyName").Value
Workbooks.Open FileName:=ActiveSheet.Range(MyFile).Value

--------------------

remove a cell name
Insert/Name/Define ... select name and Delete.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top