+ Reply to Thread
Results 1 to 20 of 20

Change the column A format to Date

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Change the column A format to Date

    Hi Guys


    I have an Excelsheet and when the data gets added in that using vba code then the first Column stores number like 20140626 but i want to convert in to date like 26/06/2014. Can this be done?

    When I try to change the format of the column to Date then it displays ######## in that column.

    Any help would be much appreciated.

    Thanks

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Change the column A format to Date

    20140624 is not a date value - it's a large integer (too large for Excel's dates, which is why you see ####). You can use a formula in another column like:
    =TEXT(A1,"0000-00-00")+0
    to convert to a true date.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Change the column A format to Date

    Try using Cdate.

    https://www.udemy.com/blog/vba-cdate/
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Change the column A format to Date

    CDate won't work with a 'date' in that format. You'd need to use Format as well.

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Change the column A format to Date

    Thanks for let me know that, Roy. Still learning!!

  6. #6
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Change the column A format to Date

    Hi aman1234,

    Try this formula and hope this will help you:

    Please Login or Register  to view this content.
    Where A2 = 20140626


    Regards,
    Paresh J
    Click on "* Add Reputation" as a way to say thanks

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Change the column A format to Date

    That will return text, not a true date. The version I posted will return a true date value, the column just needs formatting.

  8. #8
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Change the column A format to Date

    Hi romperstomper,

    Even this will return date, but will need formatting:
    Please Login or Register  to view this content.
    But, I have checked the below formula in Excel 2010.
    Please Login or Register  to view this content.
    It shows me as Date format.


    Regards,
    Paresh J

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Change the column A format to Date

    It shows in date format but it's formatted text, not a date. That may not be a problem for the OP but I wanted to point it out.

  10. #10
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Change the column A format to Date

    Hi romperstomper,

    Okk. THanksss for sharing this.

    Regards,
    Paresh J

  11. #11
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Change the column A format to Date

    Thanks romperstomper. this works fine but Can the same thing be done using vba so that column A will be automatically be replaced with Date?

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Change the column A format to Date

    You may be able to add it to your code that populates the sheet initially. What's that?

  13. #13
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Change the column A format to Date

    Romperstomper,

    The following code copies data from Access to Excel but as ScanDate has number data type so when it gets copied to Excel then column B stores Scandate in number like 20140626 but I want the code after the following code to automatically change it into 26/06/2014.

    I hope it makes sense.

    Please Login or Register  to view this content.
    Thanks

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Change the column A format to Date

    Try changing the SQL:

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Change the column A format to Date

    it gives me syntex error:
    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Change the column A format to Date

    also, Expected End of statement compile error at followinf line:

    CDate(Format(Scandate,"0000-00-00"))

  17. #17
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Change the column A format to Date

    Hi aman1234,

    Try to use,

    Please Login or Register  to view this content.

  18. #18
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Change the column A format to Date

    Sorry - forgot to double the quotes:
    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Change the column A format to Date

    Thanks a million romperstomper. Its working perfectly..

  20. #20
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Change the column A format to Date

    Glad to help. Please remember to mark Solved.

+ 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. [SOLVED] help on vba code to make list continue column and change date format
    By johnodys in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-09-2013, 12:06 PM
  2. [SOLVED] help on vba code to change the error date format as standard format mm/dd/yyyy
    By johnodys in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-13-2013, 01:10 AM
  3. Column Range with date Format MM/DD/YYYY independate of sys date Format
    By gaursh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2011, 03:31 AM
  4. Not able to change date format into proper excel date format
    By excel5111987 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2011, 08:19 AM
  5. Userform date format reverting back to us format on change event
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2009, 12:34 PM

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