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

I want to open a particular excel file with the help of macro.

ThrottleWorks

Excel Ninja
Is it possible that the macro will consider active cell value as file name & open the particular file.


For example, active cell is B1, activecell.value is “Test”, when I run the macro for opening the file,

The macro will consider “Test” as file name & will open it.


Background of the problem :- I have a macro which gives me list of file names.

Now I want user to select a particular name & paste in Range B1.

When I run second macro, the macro should consider Range B1 value as file name & should open it.


Any & every help is appreciated
 
Hi, sachinbizboy!

Second macro may be:

-----

Sub OpenFileFromCell()

Application.Workbooks.Add Range("xxx!B1").Value

End Sub

-----

where xxx is the sheet name, if needed, else just left "B1".

Regards!
 
Somethine like this would work:

[pre]
Code:
Sub MyMacro()
Dim MyPath As String
Dim MyName As String

MyPath = "C:My Documents"
MyName = Worksheet("My Sheet").Range("B1").Value

'Add file extension. Not sure whether you want .xls or 2007 extension
MyName = MyName & ".xls"
Workbooks.Open MyPath & MyName

End Sub
[/pre]
 
Back
Top