+ Reply to Thread
Results 1 to 23 of 23

Formatting Correct date using VBA

  1. #1
    Forum Contributor 323100N's Avatar
    Join Date
    08-11-2017
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    272

    Formatting Correct date using VBA

    I have this raw data from a Company System, then I have this excel tracker to dump all the information. in A1 Colum that compose of Date from Company system but when I paste it to excel tracker it has a different format like this "83115", I want to seek for an vba code that will convert those unformatted date to convert as 08/31/2015. Thank you!

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: Formatting Correct date using VBA

    eg...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

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

    Re: Formatting Correct date using VBA

    How do you know if 11115

    1/11/2015? or 11/1/2015?

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: Formatting Correct date using VBA

    "83115"
    Is the format after paste...Needs to format before paste
    So...11115 issue will not feature...

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

    Re: Formatting Correct date using VBA

    Quote Originally Posted by sintek View Post
    eg...
    Please Login or Register  to view this content.
    Never work.

  6. #6
    Forum Contributor 323100N's Avatar
    Join Date
    08-11-2017
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    272

    Re: Formatting Correct date using VBA

    the result for 83115 is 7/23/2127

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: Formatting Correct date using VBA

    @ jindon.... True, I am assuming OP situation is....
    He is copying the correct format but when it is pasted, it pastes in incorrect format i.e. 83115

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: Formatting Correct date using VBA

    Are you manually copying and pasting to excel tracker?

  9. #9
    Forum Contributor 323100N's Avatar
    Join Date
    08-11-2017
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    272

    Re: Formatting Correct date using VBA

    Yes, copying to a DOS base system then paste it to tracker

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

    Re: Formatting Correct date using VBA

    If A1 = 83115

    Go To [Data] - [TextToColumns] -[ Next] - [Next]
    Select [Date] - Select MDY from combobox then OK

    See if this works

  11. #11
    Forum Contributor 323100N's Avatar
    Join Date
    08-11-2017
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    272

    Re: Formatting Correct date using VBA

    Yeah it works for 83115 but for some different format it doesn't work e.g 7713

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

    Re: Formatting Correct date using VBA

    Yeah that would be the problem.

    If you upload a workbook and the result that you want, I will take a look at it...

  13. #13
    Forum Contributor 323100N's Avatar
    Join Date
    08-11-2017
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    272

    Re: Formatting Correct date using VBA

    Please see attached, A1 is the raw date and B1 is the desired result after clicking the command button. and also I found out that every date has a "0" in the middle so that should not be the problem e.g "030915"
    Attached Files Attached Files

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

    Re: Formatting Correct date using VBA

    Are you sure?

    If the data is all 6 degits, TextToColumns should work...

  15. #15
    Forum Contributor 323100N's Avatar
    Join Date
    08-11-2017
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    272

    Re: Formatting Correct date using VBA

    Yeah as per my observation its always 6 digits default and the text to columns will work for now I'll let you know if i encounter different scenarios. Thank you guys!

  16. #16
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: Formatting Correct date using VBA

    TRY...
    Please Login or Register  to view this content.
    Edit for range...
    Please Login or Register  to view this content.
    Last edited by sintek; 01-12-2018 at 12:11 PM.

  17. #17
    Forum Contributor 323100N's Avatar
    Join Date
    08-11-2017
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    272

    Re: Formatting Correct date using VBA

    Thank you! This work properly, how to use this using Module?

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

    Re: Formatting Correct date using VBA

    Why loop?

    This should have no error no matter how many times you run.
    Please Login or Register  to view this content.

  19. #19
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: Formatting Correct date using VBA

    Very simplistic...Tx jindon for lesson

  20. #20
    Forum Contributor 323100N's Avatar
    Join Date
    08-11-2017
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    272

    Re: Formatting Correct date using VBA

    you guys are great! thank you for all the help

  21. #21
    Forum Contributor 323100N's Avatar
    Join Date
    08-11-2017
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    272

    Re: Formatting Correct date using VBA

    Hi I more question how can I format again the Colum A back to general? I will have a seperate button for this to format again that Column. Thank you!

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

    Re: Formatting Correct date using VBA

    No error proof
    Please Login or Register  to view this content.

  23. #23
    Forum Contributor 323100N's Avatar
    Join Date
    08-11-2017
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    272

    Re: Formatting Correct date using VBA

    It works! Thank you! very much appreaciated

+ 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] Formula to automatically return date in correct cell based on date given
    By MichelleD75 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-10-2016, 01:29 PM
  2. [SOLVED] VBA: Read date and paste the date info on the correct cell. Analyse code please.
    By ropbasuel in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-10-2013, 05:32 AM
  3. How To Correct Strange Formatting?
    By Steve0492 in forum Excel General
    Replies: 3
    Last Post: 06-26-2012, 04:37 PM
  4. Correct Formula for formatting
    By rnoceda in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2011, 10:06 PM
  5. Replies: 3
    Last Post: 10-28-2010, 07:04 AM
  6. Replies: 3
    Last Post: 07-11-2009, 12:39 AM
  7. formatting a cell to display the correct date.
    By Lee in forum Excel General
    Replies: 1
    Last Post: 02-23-2006, 12:10 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