PDA

View Full Version : Advice: Redefine type of variable



obivan
05-07-2009, 12:42 AM
Hi, I need redefine variable type from DATE to STRING and vice versa. Can you get me help please?
Thank a lot

Obivan

Bob Phillips
05-07-2009, 01:26 AM
Obivan,

If you declare a variable as type variant, you can load a date into it at one instance, a text string at anotehr. VBA will automatically sub-type it for you. I don't promote this approach, but it can be done.

BTW, I have moved this to the main Excel forum.

obivan
05-07-2009, 01:47 AM
Hi XLD, thank you for your help
obivan

Kenneth Hobs
05-07-2009, 05:15 AM
Not sure why you would need to do that. It is best to use one type. You can use the convert functions like CDATE() and CSTR(). Type CDATE in the VBE and press F1 to get help.

You might also try VARTYPE(), ISDATE() and FORMAT().