Criteria for multiple files if open dialog box

ItalianPlatinum

Active Member
Joined
Mar 23, 2017
Messages
420
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Hello,
So i have current VBA that works as intended but I need to add another file into the mix to open and source. Looking to expand the existing VBA to also check if the new file exists but having trouble modifying my existing VBA to fit that into it. Here is a condensed version below. need to add as an example C:\MYFile2. where it would also check for the file existing. expanding it so File 1 not found or file 2 not found or both not found.

Sub RUN()

Dim FilePath As String
Dim TestStr As String
Dim FoundFile As Boolean

FilePath = "C:\MYFile1" & Format(Now(), "MM-DD-YY") & " " & "ME" & ".csv"

If FilePath <> "" Then
TestStr = Dir$(FilePath)
FoundFile = (TestStr <> "")
Else
FoundFile = False
End If

If FoundFile Then

REST OF MY VBA HERE

Else
MsgBox "File NOT FOUND"
End If
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Watch MrExcel Video

Forum statistics

Threads
1,129,587
Messages
5,637,252
Members
416,963
Latest member
samfuge

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top