The IsEmpty function determines if the variable has been initialized . If the cell is really empty, it is considered uninitialized from the point of view of IsEmpty . However, declaring a variable in VBA gives a default value. In this case, date type variables are essentially 0 or 30-Dec-1899 00:00:00 , as shown in the following short snippet.
Sub date_var_test() Dim dt As Date Debug.Print Format(dt, "dd-mmm-yyyy hh:mm:ss") End Sub
If you want to "remove" your code, you can also enable the true logical return of the IsEmpty function to solve the logical condition, and not for comparison with True .
If IsEmpty(Worksheets("Data").Cells(Counter, 7)) Or IsEmpty(Worksheets("Data").Cells(Counter, 9)) Then [.. do stuff] End If
Given that False is (for all purposes and tasks) zero, then this will work for your date type variables.
If Not (agreedDate or completedDate) Then [.. do stuff] End If
source share