# must be easy, trick

#### rplim2016

##### Board Regular
Hello Guys,

=IF(AND(CELL("format",A2)="D4",
CELL("format",B2)="D4",
CELL("format",C2)="D4",
CELL("format",D2)="D4"),
"is in DATE Format",)

above formula is to check if all values in A2 to D4 are in date.
my boss challenged me to simplify above formula.

please help me. ### Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

#### rplim2016

##### Board Regular
is it possible to array the formula guys?

#### James006

##### Well-known Member
Just tested again the Array Formula for you ...

https://www.mrexcel.com/forum/excel...ets-simple-count-post5247706.html#post5247706

And it does work ...

As an alternative ... a simple UDF can also perforrn the task ...

Code:
``````Function CountDates(rng As Range) As Long
Dim c As Range
Dim x As Long
For Each c In rng
If IsDate(c.Value) = True Then x = x + 1
Next c
CountDates = x
End Function``````
P.S. For your info the Cell function does not accept an Array ...

Last edited:
• rplim2016

#### rplim2016

##### Board Regular
Just tested again the Array Formula for you ...

https://www.mrexcel.com/forum/excel...ets-simple-count-post5247706.html#post5247706

And it does work ...

As an alternative ... a simple UDF can also perforrn the task ...

Code:
``````Function CountDates(rng As Range) As Long
Dim c As Range
Dim x As Long
For Each c In rng
If IsDate(c.Value) = True Then x = x + 1
Next c
CountDates = x
End Function``````
P.S. For your info the Cell function does not accept an Array ...

Thanks a lot james!

#### James006

##### Well-known Member
You are welcome ...