True or False if file exists in a folder

Copper Contributor

I'm trying to write an IF formula that would return T or F if a file exists in a network folder. Can someone help? Thanks

2 Replies

You cannot get what you are asking with built-in formulas. If you know how to use VBA User Defined Functions. then here is already an answer for this question using UDF.


Public Function CheckIfFileExists(FilePath As String)

On Error GoTo ExitWithError

If FilePath = "" Then
    CheckIfFileExists = ""
    Exit Function
End If
If Dir(FilePath) <> "" Then
    CheckIfFileExists = "File found"
    CheckIfFileExists = "File not found"
End If

Exit Function
    CheckIfFileExists = "File not accessible"
End Function

@wuzmop Great and simple solution!