+ Reply to Thread
Results 1 to 8 of 8

Trim right

  1. #1
    Registered User
    Join Date
    09-12-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    4

    Trim right

    I searched and was unable to find something that fixed my problem so sorry if this is a repost.
    I'm trying to create a macro that deletes the first part of a string in ever cell in a column. the format is Company:Part# and i want to delete the company name and colon and only leave the part# in the cell for every cell. i've gotten it to work using trim right function within a cell in excel but i need to do it in a macro. Right now i have this and it errors at the find function.
    Please Login or Register  to view this content.
    Last edited by EraseGrey; 09-14-2010 at 08:11 AM.

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Excel VB Trim right problem

    EraseGrey,

    Welcome to the Excel Forum.


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    Please Login or Register  to view this content.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Registered User
    Join Date
    09-12-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Trim right

    Stan;
    That gives me a Type Mismatch error. And of course i'm using a backup! Thank you for the response by the way.
    EG.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,291

    Re: Trim right

    If that's the only colon in the cell, then select the data, press ctrl+h, enter *: on the find box, leave the replace box blank and press Replace All.
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    09-12-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Trim right

    Sorry Romp, that just deletes everything.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,291

    Re: Trim right

    That would only happen if the cells all end in a colon too?
    Edit: oh, or if you entered just * in the Find box and not *:

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Trim right

    This macro will trim a number of cells in a given range replacing "text" and ":" with "".

    Perhaps you can adjust it to fit your needs?

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-12-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Trim right

    Quote Originally Posted by romperstomper View Post
    That would only happen if the cells all end in a colon too?
    Edit: oh, or if you entered just * in the Find box and not *:
    Ok wow, i didn't see that colon. It works great now. Thank you

+ 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