title: Excel VBA - Import from a file in the same folder with an arbitrary name but a specific number at the end
body: <p>I want to be able to import data from a file in the same folder, but it doesn't matter what it's called, but the number at the end does. Currently i have </p>
  
  <pre><code>Sub Import_Data()
  
  Dim rng As Range
  Dim WB2 As Workbook
  Dim FName As String
  Dim c1 As Worksheet
  Set c1 = Sheets("c")
  
      FName = Application.ActiveWorkbook.Path + "_w" &amp; Format((WorksheetFunction.WeekNum(Now) - 1), "00")
      Set WB2 = Workbooks.Open(Filename:=FName)
  
     c1.Range("L2:O6").Value = WB2.Worksheets(3).Range("M2:P6").Value
  
      c1.Range("L14:O18").Value = WB2.Worksheets(3).Range("M14:P18").Value
  
  WB2.Close
  
  End Sub
  </code></pre>
  
  <p>I want to change the following line from </p>
  
  <pre><code>FName = Application.ActiveWorkbook.Path + "_w" &amp; Format((WorksheetFunction.WeekNum(Now) - 1), "00")
  </code></pre>
  
  <p>To something like </p>
  
  <pre><code>FName = Application.ActiveWorkbook.Path + *Any Name before the last 2 digits* &amp; Format((WorksheetFunction.WeekNum(Now) - 1), "00")
  </code></pre>
  
  <p>So it will basically not look at the name of the sheet but will look at the 2 digits at the end.</p>
  
  <p>The week numbers will always be unique in the folder but the names might be different. E.g</p>
  
  <p>Folder may contain the following files:</p>
  
  <pre><code>Worksheet 1 w21
  Different Name w22
  Alternate w23
  </code></pre>
  
  <p>If we are in w24, i'd like it to import from "Alternate w23"</p>
  
  <p>I hope this makes sense. Thanks</p>
  
  <p>EDIT - Alternative</p>
  
  <p>If this isn't possible, It would also work if the previous weeks file had the same name as the current file. So if the active workbook was called "Workbook w23" Then it would find "Workbook w22" in the same folder. But it would need to be possible to generalise the name of the sheet. So instead of the original suggestion of <em>Any Name before the last 2 digits</em> it would be <em>The same name as the active workbook with 2 different digits at the end</em></p>