I always seem to have trouble with type-casting in VBA. I have a column of dates I want to access but I get errors (Type mismatch) no matter how I declare my variables. The data has a date and time column. Since I am not using time in this macro, I had declared the variable as Dim dateAcq As Long and dateAcq = Cells(i,j). The data in i,j is formatted as a date and should be a whole number.
I get Type mismatch errors with Integer, Long, Double, String, …
and even when I use an integer function dateAcq = Int(Cells(i,j)).
The macro seems to run well if these functions are undeclared Variants, but I am curious why I am getting errors.
Bookmarks