What wrong is this macro? Referring to following code, I don\'t understand why F
ID: 3565665 • Letter: W
Question
What wrong is this macro?
Referring to following code, I don't understand why Formula 2 works, but not Formula 1.
Does anyone have any suggestions?
Thanks in advance for any suggestions
Sub CheckFile()
Dim FilePath As String
FilePath = "='D:ABC..xls"
If FileExists(FilePath) Then Range("A1") = True Else Range("A1") = False ' Formula 1
If FileExists("D:ABC.xls") Then Range("A1") = True Else Range("A1") = False ' Formula 2
End Sub
Public Function FileExists(ByVal Filename As String) As Boolean
Dim nAttr As Long
On Error GoTo NoFile
nAttr = GetAttr((Filename))
If (nAttr And vbDirectory)) <> vbDirectory Then
FileExists = True
End If
NoFile:
End Function
Explanation / Answer
Hi
Change:
FilePath = "='D:ABC.xls"
to:
FilePath = ""D:ABC.xxls""
Note the removal of the single quote and equals sign before !!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.