Criteria for multiple files if open dialog box

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
774
Office Version
  1. 365
  2. 2019
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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

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
Back
Top