Write Procedure With Logic Test To Open File From Given Directory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to write a procedure (not sure if this is what you call it) to cause
the file "data.xls" to be opened from path "C:\data\FEB" if the month is
February (evidenced by the text "FEB" in cell L45 in worksheet "Process") and
a file with the same name to be opened from path "C:\data\MAR" if the month
is March (evidenced by the text "MAR" in cell L45 of worksheet "Process").
This may be simple for some but I don't even know where to start. Thanks!
 
Hi Carl,
the file "data.xls" to be opened from path "C:\data\FEB" if the month is
February (evidenced by the text "FEB" in cell L45 in
worksheet "Process") and


Try:

workbooks.Open FileName:="C:\data\" & Sheets
("Process").Range("L45").Value & "\data.xls"

Best

Markus
 
OK,
if I've undestood, you want to open files with the same names and
different paths variable on a cell value. If this is correct, do as
follows:

Create a command button (from the Control Toolbox) and (in the Design
Mode - always selectable in the Control Tollbox Taskbar) double click
it. A macro screen will popup with a couple of lines written:

The following code will create from cell L45 the right path and will
open the file (without ">>"):

Now, saving and then pushing the button (NOT in Design Mode) the
desired file should be opened.

Hope it Helps,
David
 
Thanks a million Markus! This worked great and has opened up a whole new
world to me!
 
Thanks, David. I will need to study this more. I was able to use the other
suggestion and it worked just fine. I still see some use for what you are
saying.
 

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