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