Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Excel 2010 - Convert Improper Date to Proper Date

Posted on 2013-01-24
11
1,005 Views
Last Modified: 2013-01-25
I have searched for Excel Date Converting, but all of the search results translates that to cell "Date" Formatting. It is nice to know how many methods of date cell formatting there are, but none of these methods solve my problem ...

I am frequently sent spreadsheets that have the Date as "20130124" and it is Formatted as "General"; re-formatting the cell as any Date Format yields "#############".

What can I do to convert the date from 20130124 to 01/24/2013, so I can use the "Short Date" Cell Format?
0
Comment
Question by:d2beetle
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 15

Expert Comment

by:Ess Kay
ID: 38815733
copy the column

then right click the column, select format, select the date format and what type you like

then paste the data back into column

hope that helps
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38815801
Use this formula and then format it as you want.
=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
0
 
LVL 13

Expert Comment

by:Shanan212
ID: 38815832
Insert a column next to it
Change "G14" with your cell where the wrong date is in

=LEFT(G14,4)&"/"&MID(G14,5,2)&"/"&RIGHT(G14,2)

Open in new window

0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 26

Accepted Solution

by:
redmondb earned 125 total points
ID: 38815879
d2beetle,

"Text to Columns" can do this without a separate column...
(1) Select the cells containing the dates.
(2) On the Ribbon's Menu Bar, select Data and then "Text to Columns".
(3) Select the "Delimited" radio button (it's probably already selected).
(4) Click on "Next".
(5) Only the Tab delimiter checkbox should be selected.
(6) Click on the "Date" radio button and select "YMD" from the dropdown.
(7) Click on "Finish".

Regards,
Brian.
0
 

Author Comment

by:d2beetle
ID: 38816394
redmondbP,

Bingo! Thanks!

One more question, there are five other date columns in the spreadsheet that need the same conversion; is there some way to automate it via VBA/Macro?



Shanan212Po and ssaqibh

Thanks for the suggestion and it does work; however I do not want to add any more columns to the spreadsheet.



esskayb2dP,

I tried that and it did not work.
0
 
LVL 13

Assisted Solution

by:Shanan212
Shanan212 earned 125 total points
ID: 38816430
Doing it Brian's way,

Sub datemaker()
    Dim iRow As Long
    
    iRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(0, 0).Row
    
    Range("A2:A" & iRow).Select
    Selection.TextToColumns Destination:=Range("A2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
        
    Range("C2:C" & iRow).Select
    Selection.TextToColumns Destination:=Range("C2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
        
    Range("F2:F" & iRow).Select
    Selection.TextToColumns Destination:=Range("F2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
End Sub

Open in new window


To modify or add more columns, change one of these blocks (change the bold letters)

    Range("A2:A" & iRow).Select
    Selection.TextToColumns Destination:=Range("A2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38816498
Thanks, d2beetle.

Shanan212's macro looks excellent. (Trivial suggestion - the date will be wider than the original value, so it might be an idea to AutoFit the columns after the change.)

Regards,
Brian.
0
 
LVL 13

Expert Comment

by:Shanan212
ID: 38816514
Thanks Brian! It was your idea of cours :)

D2beetle,

Adding to that, this code will autofit. However you have to add/change columns below

   Range("A:A,C:C,F:F").Select
    Selection.Columns.AutoFit

Open in new window

0
 
LVL 26

Expert Comment

by:redmondb
ID: 38816627
... and your code, Shanan212!
0
 

Author Closing Comment

by:d2beetle
ID: 38818816
redmondb and Shanan212,

Thanks, :) points split evenly.
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38819084
Thanks, d2beetle!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question