• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

vba that will look for a file in more than one location

I need to make Excel look in more than one location for a file, is this doable?

Some people in the firm have paths mapped to different letters. i.e. some people will have a path as S:EVERYONE\ACCT\Daily Reports\Dashboard Files\Outstanding.xls other people will have it as H:EVERYONE\ACCT\Daily Reports\Dashboard Files\Outstanding.xls.

I need excel to look in S and if it can't find it look in H

1 Solution
This code will only work if you ARE SURE either file1 or file2 exists. If there's someone else with the file at another location, you have to expand your code.

file1 = "S:\EVERYONE\ACCT\Daily Reports\Dashboard Files\Outstanding.xls "
file2 = "H:\EVERYONE\ACCT\Daily Reports\Dashboard Files\Outstanding.xls"
If Dir(file1) <> "" Then
    Workbooks.Open Filename:=file1
    Workbooks.Open Filename:=file2
End If
JagwarmanAuthor Commented:
Thanks it works fine.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now