How to count if cells contain any date/data in Excel?
Have you even met problems to count number of cells containing any date or data in a specific range in Excel? In this article, I will introduce ways to count if cells contain any date/data in Excel.
Count and select cells if contains any data in a specified range (only one click)
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
This method will introduce a VBA Macro to count cells containing dates in a specific range in Excel.
Step 1: Open the Microsoft Visual Basic for Applications window with pressing the Alt + F11 keys at the same time.
Step 2: Click the Insert > Module, and then paste the following VBA code into the Module window:
VBA: Count if cells contain any date
Function TypeCell(pRange As Range) As Variant
Dim xArr() As Variant Dim xRng As Range Application.Volatile ReDim xArr(pRange.Cells.Count - 1) As Variant xCount = 0 For Each xRng In pRange xArr(xCount) = VarType(xRng) xCount = xCount + 1 Next TypeCell = xArr End Function
Step 3: In a blank cell enter the formula =SUM(IF(TypeCell(A1:E15)=7,1,0)), and then press the Ctrl + Shift + Enter keys in a meantime.
Note: In the formula of =SUM(IF(TypeCell(A1:E15)=7,1,0)), the A1:E15 is the specific range we will count number of cells containing dates, you can change it based on your needs.
Now you will get the number of cells containing dates in the specific range.
The COUNTA function will help you figure out the number of cells with any data in a specific range in Excel easily.
In a blank cell enter the formula =COUNTA(A1:E15), and press the Enter key. In the formula, the range A1:E15 is the specific range you will count numbers of cells with data, and you can change it as you need.
Note: After selecting the specific range, we can get the cell number with any data in the Status Bar easily too.
If you have Kutools for Excel installed, you can apply its Select Nonblank Cells utility to count and select cells if contains any data quickly in a certain range with only one click.Select the range you will count cells if contain any data, and click Kutools > Select > Select Nonblank Cells. See screenshot:
And then all cells with data in the specified range are selected, and a dialog box will pop up and show how many nonblank cells have been selected. See screenshot:
Click the OK button to close this dialog box.