+ Reply to Thread
Results 1 to 10 of 10

Store date as string

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Store date as string

    Hello everyone
    I am dealing with an array of data and there is a date in it like that '01 May 2007'
    When dealing with it and populating the data it comes as dates .. and I want to keep it as string
    so I put apostrophe so as to overcome this problem ..

    But I am wondering if there is a better way or approach for that .. I tried using CStr but the same problem of being dates not string
    Thanks advanced for help
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,913

    Re: Store date as string

    Like this?

    Arr = Range("B1:B10").Text

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Store date as string

    Thanks a lot for reply
    The array doesn't come from range directly .. it is output of results

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Store date as string

    I don't understand why it doesn't work. 01 May 2007 is already a string.
    Please Login or Register  to view this content.
    and Arr = Range("B1:B10").Text will never work anyway.

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Store date as string

    Thanks a lot Mr. Jindon for reply
    I encountered an error 'Type mismatch' at this line
    Please Login or Register  to view this content.
    I think that because my regional settings are not English

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Store date as string

    That's a irrelevant issue here, adjust it for yourself.

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Store date as string

    The date is extracted from a string if that is relevant
    Please Login or Register  to view this content.
    So it appears as text and while the result in array it is a string but when populated it is populated as date (Arabic date) and that means it is converted to date ..
    Another point that may be the cause is that the array is pouplated next to column A and column A is designed as Table so the results turned to columns in that table ..

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Store date as string

    Also I checked the type as you did while in the loop and it is already String type
    The problem occurs only when the dates in the array populated

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Store date as string

    That's also irrelevant.

    When you dump the data into the RANGE, cell in Excel have AUTOCASTING functionality, so if it recognized as date, it automatically put the data as date.
    You will need to change the cell format as TEXT, before dump the data.

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Store date as string

    Thank you very much Mr. Jidnon
    That did the trick you are awesome.
    Best and Kind Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Store String Values to Avoid Re-Using
    By visualnotsobasic in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-11-2018, 05:02 PM
  2. trying to convert string variable to barcode font and store as new string var
    By mike_tako in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 05-11-2018, 04:36 PM
  3. How can I store more than 255 charachters in a VBA string?
    By kbdb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-28-2017, 06:00 AM
  4. Make Macro Store Whatever is in a Cell as a String
    By PleaseHelpMe3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2016, 04:51 PM
  5. store cells value as a string variable
    By sebdor in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-02-2014, 03:31 PM
  6. store contents of entire column as string
    By mpower87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-20-2010, 01:46 AM
  7. seprate and store string in arrays
    By ilyaskazi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-29-2005, 10:22 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1