+ Reply to Thread
Results 1 to 5 of 5

Convert Excel cells stored as text to date and number coming from notepad

  1. #1
    Registered User
    Join Date
    05-18-2010
    Location
    Brazil
    MS-Off Ver
    Excel 2003
    Posts
    14

    Post Convert Excel cells stored as text to date and number coming from notepad

    Hi all !!


    I am using the code below from the great Leith Ross to import delimited text from an unsaved file opened on Notepad to an Excel worksheet.

    The problem is that coping all and pasting all the text from notepad to a worksheet is giving errors on the numbers and dates. Appears little green triangles on the left top o the cells asking to covert text to numbers and 2 year digit date to a 4 year digit date.

    I tried to uncheck the Text date with 2 digit years and Number stored as text in the Excel error checking options as Leith suggested (I could use code for that). That will just make the green triangles disappear.

    If I try to custom the format of the date like 25-Jul-08 or make operations with the numbers using vba code it won't work.

    Strange enougth is that if copy all the text from notepad and paste on the worksheet it give no errors in the numbers and will make all 2 digit year date into 4 digit... just curious why no code can change the cells perhaps when I paste I need do some sort paste special....

    The text file is attached and the code that is pulling the text done Leith is below :

    Please Login or Register  to view this content.
    Link from previous threat:

    http://www.excelforum.com/excel-prog...epad-text.html
    Attached Files Attached Files
    Last edited by Fire_d; 05-29-2010 at 02:38 PM.

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Convert Excel cells stored as text to date and number coming from notepad

    Don't know how far this helps but this little trick might
    Enter 1 in an empty cell and copy the value
    Select all your values withe the triangle in xl - Right Click - Select Paste Special - Check " multiply" and Ok

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Convert Excel cells stored as text to date and number coming from notepad

    Hello Fire_d,

    I solved the issue with the dates by applying formats to columns with dates. The same could be done for the numbers and currency. I am still mystified by why setting the column formats in Excel doesn't behave the same as when done with VBA. Here is the update macro and sample workbook you run also.
    Please Login or Register  to view this content.


    Main Macro
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    05-18-2010
    Location
    Brazil
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Convert Excel cells stored as text to date and number coming from notepad

    Hi arthurbr,

    OK that will work, but I need to solve the problem with VBA code.
    Coverting what you suggested into code won't work unfortunately.

    Thanks for your reply !

  5. #5
    Registered User
    Join Date
    05-18-2010
    Location
    Brazil
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Convert Excel cells stored as text to date and number coming from notepad

    Hi Leith,

    The cells get formatted and I just can see that by right clicking the cell to see the formats.
    The cells simple does not respond to the formatting.
    In the Format Cells screen it shows that the cell is formatted but it does not update on the cells.
    I still getting green triangles and cannot make operations with numbers nor see the date formatted properly.

    The cells gets formats only manually like "F2" and "Enter". You enter the cells as for editing and go out.

    The code I did below solve the problem leaving the macro slow. I do not like of using this methods.
    See if you can help with another idea. Anyway I will test your code at my work and tell if I get better results.


    Please Login or Register  to view this content.

    Thank you and Regards,
    Fire_d
    Last edited by Fire_d; 05-31-2010 at 12:38 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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