TopPicLogo TopPicText

MS Excel - Подсчёт заполненных строк в листе

Dim objExcelApp As Object
Dim objWorkbook As Object
Dim objWorksheet As Object
Dim strPath As String

    strPath = "d:\Downloads\Book1.xlsx"
    Set objExcelApp = CreateObject("Excel.Application")
    'Set objExcelApp = GetObject(, "Excel.Application")
    Set objWorkbook = objExcelApp.Workbooks.Open(strPath)
    'Set objWorkbook = objExcelApp.ActiveWorkbook
    Set objWorksheet = objWorkbook.Worksheets(1)

'Заполненные строки на листе
    Debug.Print objWorksheet.usedrange.rows.Count

    On Error Resume Next
    objWorkbook.Close
    Set objWorkbook = Nothing
    objExcelApp.Quit
    Set objExcelApp = Nothing
    Err.Clear


Назад ToTop
L.E. 17.12.2012
Рейтинг@Mail.ru