+ Reply to Thread
Results 1 to 9 of 9

Macro to remove certain characters end of a cell value

  1. #1
    Registered User
    Join Date
    06-09-2014
    Posts
    3

    Macro to remove certain characters end of a cell value

    Hello all,
    I am currently using the following formula to remove the letter "R" from the end of cells [=IF(ISNUMBER(--RIGHT(A3)),A3,LEFT(A3,LEN(A3)-1))].

    However, I would like a macro to accomplish this goal, along with something else. I have a list of values as follows:
    CHD152-2
    CHD115-1
    CHD40-3
    RE224
    HPC644R
    DOC020R
    HPC594R

    What I need is a macro that will remove any instance of "R", "-1", "-2", "-3", "-4" from the end of a cell. neither of the 5 values listed in the last sentence are present, the the cell will be unchange. So, after running, the above values would look like this:
    CHD152
    CHD115
    CHD40
    RE224
    HPC644
    DOC020
    HPC594


    Can anyone help me with this?

    Thank you

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    11,204

    Re: Macro to remove certain characters end of a cell value

    workbook not required,
    Last edited by protonLeah; 06-09-2014 at 04:23 PM.
    Ben Van Johnson

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    31,613

    Re: Macro to remove certain characters end of a cell value

    A3:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Do you really need a macro?


    Regards, TMS
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    06-09-2014
    Posts
    3

    Re: Macro to remove certain characters end of a cell value

    Thank you for the formula, it works perfectly. The only reason I requested a macro is because of how frequently it would be used and the technical knowledge of the person who will be using the macro. It would be much easier to ask her to click 1 button and have it apply this formula automatically on the A column rather than have her paste this formula, fill, and copy/paste values numerous times a day. If a macro accomplishing this would be extremely complicated then it's not too big of a deal, but that is the reasoning.

    Thanks so much for your help.

    -- Based on post #2, do I need to attach a workbook?

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    31,613

    Re: Macro to remove certain characters end of a cell value

    Please Login or Register  to view this content.

    Regards, TMS

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 2019; O365
    Posts
    18,994

    Re: Macro to remove certain characters end of a cell value

    Here is an alternative solution
    Please Login or Register  to view this content.

  7. #7
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    11,204

    Re: Macro to remove certain characters end of a cell value

    Below modifies/replaces values in column A
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-09-2014
    Posts
    3

    Re: Macro to remove certain characters end of a cell value

    Those macros work great, thank you all for your help

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    31,613

    Re: Macro to remove certain characters end of a cell value

    You're welcome. Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. [SOLVED] Remove first 5 characters from a cell
    By PeterR in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-05-2014, 06:31 AM
  2. remove spaces and characters in hyperlink - macro
    By missy22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2013, 09:23 AM
  3. Replies: 8
    Last Post: 12-17-2012, 05:30 AM
  4. [SOLVED] Macro to remove multiple characters in column?
    By emil9216 in forum Excel General
    Replies: 3
    Last Post: 07-31-2012, 09:29 AM
  5. Macro to remove any numeric characters from just the last value
    By Renfield in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-09-2010, 12:03 PM

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