Cell Data Types (Date vs. Double)

M

Mike

Hello All:

I have a spreadsheet with two columns both containing serial date/time.
Column A is formatted using a valid date format and column B is formatted
using a valid time format.

If I use the following:

SourceArray = Range.Value
Assuming that Range is a selection of two columns and at least one row.

TypeName(SourceArray(1,1))
returns Date
TypeName(SourceArray(1,2))
returns Double

Does Excel not evaluate a column formatted as time to be a valid portion of
a date and therefore type the value as a Date?

Any insight would be greatly appreciated.

Mike.
 
B

BrianB

Don't really know the answer, but VBA obligingly changes data types to
whatever the variable is formatted to. This can be very useful, for
example, when wanting to convert Text to numbers or vice versa.

Perhaps, in this case, it recognises your date data as such and does
its thing (because it just loves to convert dates to American mm/dd/yy
) but does not recognise Times.

"It's a feature, not a bug.":rolleyes:
 
M

Mike

Everyone:

Brian, thank you for you response.

The following is a debug.print of the values I am working with.

Before Format: 37417.3433796296, 37417.3433796296
After Format: 10/06/2002 8:14:28 AM, 37417.3433796296

Format Strings: dd/MM/yyyy, h:mm:ss

Notice how the Col A value has been converted when a date format is applied
but the Col B value remains unchanged.
 
Top