title: How to extract a file name from its path in vba
body: <p>I am writing a code, where I am opening a file for extracting data. I am currently using following code; I want to extract the file name from the path and store it in a particular range. This the code:</p>
  
  <pre><code>FilePath = Application.GetOpenFilename("Excel Files (*.xlsx), *.xls")
  If FilePath &lt;&gt; False Then
  Range("D6").Value = FilePath
  file = Range("D6").Value
  Range("D6").Clear
  End If
  </code></pre>