title: How to read a cell value from an excel file
body: <p>I have a folder that contains one excel workbook each for each employee (only one worksheet in the workbook).  I wanted open each of the employee workbook and read the cell in $A$1, and write to another worksheet.  Ultimately, I will have a worksheet which will contain all $A$1 cells each of the workbook.  I wrote the following code, but the line I indicated is not working for some reason.  Can you suggest how to do this?  Thanks</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  Const FOLDER As String = "c:\Junk\Employee Files\"
  
  On Error GoTo ErrorHandler
  
  Dim i As Integer
  i = 0
  
  Dim fileName As String
  
  fileName = Dir(FOLDER, vbDirectory)
     Do While Len(fileName) &gt; 0
  
      If Right$(fileName, 4) = "xlsx" Then
          i = i + 1
  
          Dim currentWkbk As Excel.Workbook
           Set currentWkbk = Excel.Workbooks.Open(FOLDER &amp; fileName)
           Cells(i, 1) = "Employee " &amp; 1
          'The line above works perfectly
           Cells(i, 2) = currentWkbk.Range("A1").Value   
          'The line doesn't work.  above works perfectly
      End If
      fileName = Dir
    Loop
  
  ProgramExit:
     Exit Sub
  ErrorHandler:
    MsgBox Err.Number &amp; " - " &amp; Err.Description
    Resume ProgramExit
  
  End Sub
  </code></pre>