title: Open workbook, count a range and write count into another workbook
body: <p>I have a macro in a Excel workbook and I am performing count operation from different files and update it in the file which has macro.</p>
  
  <pre><code>Private Sub count_Click()
      Dim MyCount(1 To 3) As Long
      Dim myData As Workbook
      Dim Rng As Range
  
      Set myData = Workbooks.Open("C:\Users\xyz\Desktop\cas\Book3.xlsx") ' selecting a workbook'
  
      With myData.Worksheets("sheet1")
          Set Rng = Intersect(.Columns(1), .UsedRange)
          MyCount(1) = WorksheetFunction.CountA(Rng)
      End With
  
      With myData.Worksheets("sheet1")
          Set Rng = Intersect(.Columns(5), .UsedRange)
          MyCount(2) = WorksheetFunction.CountA(Rng)
      End With
  
      'MsgBox "count is " &amp; MyCount(1)
      Set myData = Workbooks.Open("C:\Users\xyz\Desktop\cas\Book2.xlsm")
         ' the workbook where I want the values to be transferred'
  
      With myData.Worksheets("sheet1").Range("a1")
          .Offset(RowCount, 0) = MyCount(1)
      End With
  
      With myData.Worksheets("sheet1").Range("a2")
          .Offset(RowCount, 0) = MyCount(2)
      End With
  End Sub
  </code></pre>
  
  <p>I have tried opening the workbook and updating the values, but the values are not displayed.
  It is probably because the instance of the workbook is open and it is unable to update. </p>