Posts by jg2703

    Re: VBA: Macro to loop through range and remove certain data after the last hyphen



    Batman
    Thanks for your code - works fine, but it comes up with the error 'Unable to get the Match property of the WorksheetFunction class' on the

    Code
    If IsNumeric(WorksheetFunction.Match(EndChars, FindChars, 0)) Then

    line.
    Do you know what's wrong?
    Thanks everyone for the quick + helpful replies!
    jg2703


    -------
    EDIT:


    It seems to be when it finds an ending that isn't in the array.... but there will be loads of them in the list :?:
    is there a way round this?

    Hoping someone can help me with this -


    I basically have a sheet that includes data like so:


    AAA-IK-10
    BBB-09
    CCC
    DDD-TT-2XL
    EEE-R-L


    And I need a Worksheet_Change macro that runs through column "A" and deletes any data after the last hyphen, if the data corresponds to a list like so:


    -S
    -M
    -09
    -10
    etc.


    Can someone help?


    I found this macro which does a similar job (but not the same) but i can't modify it correctly:



    Thanks in anticipation.
    - jg2703