Monday, September 12, 2011

Count Non Blank Rows and Non Blank Cell

if you want to count the non blank rows and non blank cells in a sheet.

Here is the code-

Sub count_non_blank_rowsand_cells()
Dim i As Long

For i = 1 To Sheets(1).Range("a1").SpecialCells(xlLastCell).Row
If Application.WorksheetFunction.CountA(Sheets(1).Rows(i & ":" & i)) > 0 Then
k = k + 1
End If
Next i
MsgBox "Non -Blank Rows --------> " & k
MsgBox "Non -Blank Cells --------> " & Application.WorksheetFunction.CountA(Sheets(1).UsedRange)

End Sub

No comments:

Post a Comment

Import data from SQL

Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...