Hello AirgasRob.
AirgasRob said:
I am trying to run code to detect if 4 files exist before I try to
import them.
I got the first file check to work fine but I am unsure how to have
it check for all 4 files before running the rest of the code.
If Dir("C:\TransferStation\FILE1.txt") = "" Then
MsgBox ("File doesn't exist")
Else
'Run the rest of the sub
Maybe like this:
If Dir("C:\TransferStation\FILE1.txt") = "" Then
MsgBox ("File1 doesn't exist", vbExclamation, "Import")
ElseIf Dir("C:\TransferStation\FILE2.txt") = "" Then
MsgBox ("File2 doesn't exist", vbExclamation, "Import")
ElseIf Dir("C:\TransferStation\FILE3.txt") = "" Then
MsgBox ("File3 doesn't exist", vbExclamation, "Import")
ElseIf Dir("C:\TransferStation\FILE4.txt") = "" Then
MsgBox ("File4 doesn't exist", vbExclamation, "Import")
Else
'Run the rest of the sub
End If
Or like this:
Select Case ""
Case Dir("C:\TransferStation\FILE1.txt")
MsgBox ("File1 doesn't exist", vbExclamation, "Import")
Case Dir("C:\TransferStation\FILE2.txt")
MsgBox ("File2 doesn't exist", vbExclamation, "Import")
Case Dir("C:\TransferStation\FILE3.txt")
MsgBox ("File3 doesn't exist", vbExclamation, "Import")
Case Dir("C:\TransferStation\FILE4.txt")
MsgBox ("File4 doesn't exist", vbExclamation, "Import")
Case Else
'Run the rest of the sub
End Select