title: how to open a file using IF in VBA
body: <p>I would like to write a code which open more than one .xlsx files, depending the conditions. I wrote this one:</p>
  
  <pre><code>Sub Macro()
      Dim ColumnNumb As Integer
      Dim FileName(14 To 16) As String
      Dim i As Integer
      ColumnNumb = 2
  
      For i = 14 To 16
          FileName(i) = Cells(i, 1).Value
          If Workbooks("Book1.xlsm").Worksheets("Input").Cells(14, ColumnNumb) = "Yes" Then
              Workbooks.Open FileName:="C:\Excel\" &amp; FileName(i), UpdateLinks:=3
              'MsgBox FileName(i)
           End If
      Next i 
  End Sub
  </code></pre>
  
  <p>The "Workbooks.Open..." line which is not working. However I use only the next line (MsgBox) instead of "Workbooks.Open...", then it is working perfectly. </p>
  
  <p>Thanks in advance</p>