+ Reply to Thread
Results 1 to 6 of 6

Using TRIM, SUBSTITUTE & CLEAN

  1. #1
    Registered User
    Join Date
    07-10-2008
    Location
    West Palm Beach
    MS-Off Ver
    2007
    Posts
    41

    Using TRIM, SUBSTITUTE & CLEAN

    Good afternoon all. I've got a spreadsheet that I must manually reformat every three months because when I export it from a txt file it comes out pretty unusable.

    Columns A-D are fine. Columns E, G, H and J are time, with am/pm formats. The others, columns K-S are hours and minutes. Apparently, in just about all of the columns there are empty spaces that need to be removed. In the time columns I can then do a quick replace and put a space between the last minute and the a or p to put it into the proper time format. Of course I'd use the custom number for this as well.

    I was reading about using TRIM, SUBSTITUTE & CLEAN and I think this is what may work, but honestly, bot totally lost with how to do this. Can anyone help? Thanks for looking.
    Attached Files Attached Files

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

    Re: Using TRIM, SUBSTITUTE & CLEAN

    You can use this formula in V8 (for example):

    =TIMEVALUE(LEFT(G8,LEN(G8)-1))+IF(RIGHT(G8)="p",0.5)

    to change the value in G8 into a proper time (format the cell in the style you want). Then this can be copied across for the other columns, and then copied down as required. You can fix the values, then copy/paste over the original values.

    Hope this helps.

    Pete

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Using TRIM, SUBSTITUTE & CLEAN

    You could judiciously use find/replace...
    Select appropriate ranges then:
    Find: <-that's a space
    Replace with: (leave this blank)

    Find: a <- letter-a
    Replace with: a <-that's a space then a letter-a

    Find: p <-letter-p
    Replace with: p <-that's a space then a letter-p

    After that, all of the time-text will be converted to Excel time-values.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Registered User
    Join Date
    07-10-2008
    Location
    West Palm Beach
    MS-Off Ver
    2007
    Posts
    41

    Re: Using TRIM, SUBSTITUTE & CLEAN

    Thanks for such a quick reply Pete. So after trying, I see that it didn't actually change the column itself, but then I can copy and paste special over the original column, ok, so now I'm reading the end of your sentence. Thanks so much. I appreciate it greatly!

    Sue

  5. #5
    Registered User
    Join Date
    07-10-2008
    Location
    West Palm Beach
    MS-Off Ver
    2007
    Posts
    41

    Re: Using TRIM, SUBSTITUTE & CLEAN

    Ron, great to know. I had been doing that with the a and the p, but did not know about the < for a space. Ah ha.... Yes, that will work, but if Pete's will do it all with a copy and paste, that might be quicker. Will try both. Thanks.

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Using TRIM, SUBSTITUTE & CLEAN

    Quick note: put an actual space in the Find What box...the "<" is just a pointer I used.

+ 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. When TRIM() and CLEAN() fail.
    By fhalejr in forum Excel General
    Replies: 7
    Last Post: 01-02-2014, 02:12 AM
  2. [SOLVED] Clean and Trim Not Working
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-05-2013, 07:14 PM
  3. Can't 'trim' or 'clean' spaces
    By [email protected] in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-05-2010, 07:06 PM
  4. Clean and Trim
    By tl7410 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2009, 03:03 PM
  5. Trim, clean and substitute function do not work for these data
    By radzian in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-02-2008, 07:59 AM

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