Sub CurrentRegionExample()
Dim rg As Range
Dim myWorksheet As Worksheet
Set myWorksheet = ThisWorkbook.Worksheets("Sheet1")
Set rg = myWorksheet.Cells(1, 1).CurrentRegion
myWorksheet.Range("I2").Value = rg.ListHeaderRows
myWorksheet.Range("I3").Value = rg.Columns.Count
Set rg = rg.Resize(rg.Rows.Count - rg.ListHeaderRows,rg.Columns.Count).Offset(1, 0)
Debug.Print rg.Rows.Count
Debug.Print rg.Cells.Count
Debug.Print Application.WorksheetFunction.CountBlank(rg)
Debug.Print Application.WorksheetFunction.Count(rg)
Debug.Print rg.Rows.Count + rg.Cells(1, 1).Row - 1
Set rg = Nothing
Set myWorksheet = Nothing
End Sub
|