title: I want to count a non empty rows of a particular column from one excel workbook and update it to another
body: <pre><code>Dim count As Integer
  Dim myData As Workbook
  Dim col As Range, rng As Range, n#, b#
  Set col = Columns(1) 'choose the column to count the values from           
  SetmyData=Workbooks.Open("C:\Users\xyz\Desktop\cas\Book3.xlsx")'selecting a workbook'
          Worksheets("sheet1").Select
              Set rng = Intersect(col, ActiveSheet.UsedRange)
              On Error Resume Next
                  b = rng.Cells.SpecialCells(xlCellTypeBlanks).count'applying the count function'
                  n = rng.Cells.count - b - 1
              On Error GoTo 0
          Worksheets("sheet1").Select
          count = n
          Set myData = Workbooks.Open("C:\Users\xyz\Desktop\cas\Book2.xlsx")'used to update the data in another workbook
          Worksheets("sheet1").Select
  </code></pre>
  
  <p>I am not able to select the workbook to apply count algo.
  run time error-  application defined or object defined error</p>