How to check or determine data type of cell?
In certain case, you may want to know the data type of the values in the cells, such as blank, error, date or something else. May be your first thought is the Type function in Excel, but this function just can check four types of the data which is not incomplete, so here, I can talk about another method to help you solve this task.
- 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.
In Excel, you can create User Defined Function to check the data type, please do with the following steps:
1. Hold down the Alt + F11 keys in Excel, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following macro in the Module Window.
VBA code: Check or determine the data type in Excel
Function CellType(pRange As Range) 'Updateby20140625 Application.Volatile Set pRange = pRange.Range("A1") Select Case True Case VBA.IsEmpty(pRange): CellType = "Blank" Case Application.IsText(pRange): CellType = "Text" Case Application.IsLogical(pRange): CellType = "Logical" Case Application.IsErr(pRange): CellType = "Error" Case VBA.IsDate(pRange): CellType = "Date" Case VBA.InStr(1, pRange.Text, ":") <> 0: CellType = "Time" Case VBA.IsNumeric(pRange): CellType = "Value" End Select End Function
3. Then save and close this code, go back to the worksheet, and enter this formula =CellType (A1) into a blank cell besides your data range, see screenshot:
4. Then drag the fill handle over to the cells which you want to contain this formula, and all data types have been extracted from the cells, see screenshot: