用ADO或DAO,将数据源设置为该EXCEL的某张表,然后检索出recordset.recordcount的值就知道EXCEL中有几行了。

解决方案 »

  1.   

    那是不可以的,你会发现recordset.recordcount的值是-1,我也在做这个东东。只能用
     Do
            ' Get the next value.
            new_value = Trim$(excel_sheet.Cells(row, 1))        ' See if it's blank.
            If Len(new_value) = 0 Then Exit Do
     Loop
      

  2.   

    为什么要循环?
    你可以用SQL语句直接导入的呀?
      

  3.   

    recordset.recordcount的值是-1是因為你的recordset的參數不對,
    這樣
    rstXls.open "select .....",cnnXls,adopenstatic,adlockreadonly
    就可以用recordset.recordcount了sula_azoth(力力昂) 的方法不好,因為如果Excel表中有空數據就會出錯,而ado可以自動檢查,建議使用ado
      

  4.   

    去下载微软的官方例子:
    http://support.microsoft.com/default.aspx?scid=KB;en-us;q278973
      

  5.   

    就是,同意 sindyzhou(比較菜) ,正确的读,是可以知道记录总数的。