Solved

Opening an Excel spreadsheet with a Macro where the path is within an Excel Cell

Posted on 2015-02-22
5
101 Views
Last Modified: 2015-02-22
Hi Guys, I have an Excel macro which opens a spreadsheet path called : "g:\Finance\Price\Jan\Summary300115.xlsm" . It is variable path as the month folder changes (eg. Jan -> Feb). I want to feature the path on a Procedure tab from the source spreadsheet within cell "A10" and want to run the Macro so it open whatever path is in this Cell so all the members of my team who do not know about Macros can run knowing which spreadsheet they are opening. How do I do this? Cheers Justin
0
Comment
Question by:Justincut
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40624140
Hi
Is this what you are looking for?
If your full path is in cell A10, the below macro will open it.

Put this in A10: g:\Finance\Price\Jan\Summary300115.xlsm
Then run this macro
Workbooks.Open Filename:=Range("A10")

Open in new window

0
 

Author Comment

by:Justincut
ID: 40624145
Yep. Is there a way I can link the path to change when the Month changes eg. Jan -> Feb without me having to physically type it?
0
 
LVL 11

Accepted Solution

by:
Wilder1626 earned 500 total points
ID: 40624153
What you can also do is for example

Put in A10: g:\Finance\Price
Put in B10: Summary300115.xlsm

Then run the below macro
Workbooks.Open Filename:=Range("A10") & "\" & Format(Now, "mmm") & "\" & Range("B10")

Open in new window

0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40624156
This can also tell you if the folder does not exist:

On Error GoTo HANDLER
Workbooks.Open Filename:=Range("A1") & "\" & Format(Now, "mmm") & "\" & Range("A2")
HANDLER:
MsgBox "Folder does not exist"

Open in new window

0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40624162
You can also do the below. It will put in the message the path it's looking for:
On Error GoTo HANDLER
Workbooks.Open Filename:=Range("A10") & "\" & Format(Now, "mmm") & "\" & Range("B210")
Exit Sub
HANDLER:
MsgBox Range("A10") & "\" & Format(Now, "mmm") & "\" & Range("B10") & " Folder does not exist"

Open in new window

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question