+ Reply to Thread
Results 1 to 9 of 9

Trim and/or Clean keep removing the date format of cells

  1. #1
    Forum Contributor
    Join Date
    11-11-2004
    MS-Off Ver
    pro + 2019
    Posts
    134

    Trim and/or Clean keep removing the date format of cells

    Good morning Gurus,

    I have a column of dates (mm/dd/yyyy and mm/dd/yy).

    How it came to me has some spaces on both ends--blank lines and such.

    I wanted to use trim and clean to ensure just the date is left in the cell.


    When I run it, some cells work perfectly and some dates gets converted back to an integer value even though the cell where the formula is has been formatted to a date.

    Is there some prep work on the original column I should be doing? Some dates are fine which removes the concern about the "/" getting cleared.

    thanks as always.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: Trim and/or Clean keep removing the date format of cells

    When you run what exactly? Are you talking about a formula or VBA code?

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    11-11-2004
    MS-Off Ver
    pro + 2019
    Posts
    134

    Re: Trim and/or Clean keep removing the date format of cells

    No, when I'm using Clean or Trim

    A1: 9/17/2021 <---has extra spaces and such in this cell making when it was imported from an email. need to reduce to just the date in there.

    b1: =clean(a1) or =trim(a1)

    b1 is now "44456" (the serial date)


    No need to attach the workbook, this is literally all there is (unless you want 300 rows of the A1 / B1 I put up here . )

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,604

    Re: Trim and/or Clean keep removing the date format of cells

    The functions TRIM and CLEAN will return text values, so you may have to do this:

    =--TRIM(cell)

    and format the cell as a date in the style you prefer. The double unary minus in front of the function will return a numeric value, which can be interpreted as a date - other approaches include adding zero and multiplying by 1.

    Hope this helps.

    Pete

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: Trim and/or Clean keep removing the date format of cells

    Just format the column as SHORT DATE.

    If that's not it, attach a workbook - it's just guesswork without one.

  6. #6
    Forum Contributor
    Join Date
    11-11-2004
    MS-Off Ver
    pro + 2019
    Posts
    134

    Re: Trim and/or Clean keep removing the date format of cells

    Hmm, that seems to work. thank you.

    Going to go read on that feature now. I've always seen that with sum product and never tried it on a date.

  7. #7
    Forum Contributor
    Join Date
    11-11-2004
    MS-Off Ver
    pro + 2019
    Posts
    134

    Re: Trim and/or Clean keep removing the date format of cells

    Quote Originally Posted by AliGW View Post
    Just format the column as SHORT DATE.

    If that's not it, attach a workbook - it's just guesswork without one.
    I'll take a look. I thought I had formatted it as several types before writing here. the unary is working now though I like to see different angles for my toolbox.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: Trim and/or Clean keep removing the date format of cells

    No - go with Pete - he's seen what I didn't see.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  9. #9
    Forum Contributor
    Join Date
    11-11-2004
    MS-Off Ver
    pro + 2019
    Posts
    134

    Re: Trim and/or Clean keep removing the date format of cells

    will do. thanks.

+ 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. Replies: 10
    Last Post: 08-09-2017, 02:17 AM
  2. Using TRIM, SUBSTITUTE & CLEAN
    By scarames in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-18-2014, 03:13 PM
  3. When TRIM() and CLEAN() fail.
    By fhalejr in forum Excel General
    Replies: 7
    Last Post: 01-02-2014, 02:12 AM
  4. [SOLVED] Clean and Trim Not Working
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-05-2013, 07:14 PM
  5. Can't 'trim' or 'clean' spaces
    By [email protected] in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-05-2010, 07:06 PM
  6. Clean and Trim
    By tl7410 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2009, 03:03 PM
  7. Can you stop the Trim function translating hyphenated cells into date format?
    By iterature in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-14-2007, 09:40 AM

Tags for this Thread

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