Consulting

Results 1 to 4 of 4

Thread: Advice: Redefine type of variable

  1. #1
    VBAX Regular
    Joined
    Apr 2009
    Posts
    8
    Location

    Advice: Redefine type of variable

    Hi, I need redefine variable type from DATE to STRING and vice versa. Can you get me help please?
    Thank a lot

    Obivan

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Apr 2009
    Posts
    8
    Location
    Hi XLD, thank you for your help
    obivan

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    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().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •