title: Check if the file exists using VBA
body: <pre><code>Sub test()
  
  thesentence = InputBox("Type the filename with full extension", "Raw Data File")
  
  Range("A1").Value = thesentence
  
  If Dir("thesentence") &lt;&gt; "" Then
      MsgBox "File exists."
  Else
      MsgBox "File doesn't exist."
  End If
  
  End Sub
  </code></pre>
  
  <p>In this when i pickup the text value from the input box, it doesn't work. If however, if remove <code>"the sentence"</code> from If <code>Dir()</code> and replace it with an actual name in the code, it works. Can somebody help?</p>