VBA Code to Count Non-Blank Cells in Excel

This code counts the number of non-blank cells in the selected range.

VBA Code:

Sub CountNonBlankCells()
    Dim count As Long
    
    count = Application.WorksheetFunction.CountA(Selection)
    MsgBox "Count: " & count
End Sub

Check All VBA Codes

Join Our Telegram Group techguruplus telegram group Join Our WhatsApp Group techguruplus whatsapp group

Leave a Comment