title: Excel VBA using DIR function with wildcard and values from cell
body: <p>I'm somewhat new to Excel VBA and am having trouble reading cell values and using them to find a file path and open the file. Here are some of the relevant facts (hopefully this is adequate specificity but please let me know if I am missing other relevant information). </p>
  
  <ul>
  <li>I have the first name and last name of each person in adjoining cells, e.g. first name in F4 and last name in G4. </li>
  <li>The files I am trying to open currently all start with "LastName, FirstName" but have different characters after them that don't follow a pattern. I'm trying to use a wildcard to make up for those unknown characters. </li>
  <li>All the files are stored in "Z:\Documents\Warehouse Personnel Updates\" and they are all .xlsx files. </li>
  </ul>
  
  <p>Eventually I'm going to create a loop to open multiple files for each person listed, but currently I am just focusing on getting one open.</p>
  
  <p>Here is the code I currently have:</p>
  
  <pre><code>Sub findFile()
  
  Dim Folder As String
  Dim FileName As String
  Dim FirstName As String
  Dim LastName As String
  
  FirstName = Range("F4").Value
  LastName = Range("G4").Value
  
  Folder = "Z:\Documents\Warehouse Personnel Updates\"
  
  FileName = Dir(Folder &amp; LastName &amp; ", " &amp; FirstName &amp; "*.xlsx")
  
  Workbooks.Open FileName
  </code></pre>
  
  <p>When I run this, I get "Run-time error '1004': Sorry, we couldn't find ." Just a space and then a period to end the sentence. It seems like it isn't reading the filename at all. </p>
  
  <p>If anyone has insight to what I am missing, I would appreciate it! Thanks!</p>