Macro to pull out multiple entries of same pattern in a cell is not working

  • I have a worksheet (Sheet1) that contains about 10,000 cells in ColumnD full of textual data


    Each Cell in Column D (From D2) contains lot of text with some special charecters in it and out of that i want to pull out a pattern like this ####-### where each # is a digit.


    This pattern does not appear at a set place in each cell and there are multiple entries of this in each cell.


    My requirement is to pull out a pattern and put it in Column E (If it is only 1 entry as per the pattern)


    If there are multiple entries of the same pattern (the return value should be placed in the same row and subsequent columnns)


    If it is a single entry i can use this formula but i have multiple entried in one cell. So i am using the below code but it is not working. Not sure what wrong i am doing.


    =MID(D2,FIND("-",D2)-4,8)



    D2 - MS09-062


    D3 -
    MS06-030
    MS08-068
    It should Return (MS06-030 in E3, MS08-068 in F3)


    D4 -
    MS09-037, MS08-048
    It should Return (MS09-037 in E4, MS08-048 in F4)


    D5-
    MS08-033, MS09-028, and MS09-047


    D6-
    MS08-055, MS09-017, MS10-017, MS10-004, MS10-023, MS10-028, MS09-068, and MS09-027
    It should Return (MS08-055 in E6, MS10-017 in F6, MS10-023 in G6,...........)

  • Re: Macro to pull out multiple entries of same pattern in a cell is not working


    Hi kumarma,


    try..

  • Re: Macro to pull out multiple entries of same pattern in a cell is not working


    Hi Pike,


    Thanks, but it is not working. It says subscript out of Range.


    As per the pattern I think the code needs to be modified


    "*??##-###*" to "*??####-###*"


    Total 8 characters and before - there are 4 characters

  • Re: Macro to pull out multiple entries of same pattern in a cell is not working


    Perhaps:

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: Macro to pull out multiple entries of same pattern in a cell is not working


    Yeah, but that's longer so more typing. ;)

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!