Macro to help match and sort data

  • [TABLE="width: 1324"]

    [tr]


    [TD="colspan: 4"]Hi, I am looking for a formulae or a script which would help me execute this problem.


    Column B contains the name of the sample and column A contains the following breakdown of the sample but this data contains other sample informations.
    Every sample is Column B starts with a Character ID (A to Z) followed by a space and then "-". Example (B - or A - )
    The data which lists the breakdown of the sample in Column A will also start with the same character ID but can have a number attached to it (Number ID range A1-A99).


    In Column Output 1 - I want to extract the relevant sample breakdown data from Column A for the sample listed in column B.
    Example - If Sample started with the ID "B -", I want the ouput1 cell to contains all the sample data starting with "B and a number"


    In Column Output 2 - I want to copy the data from Output 1 but without the starting ID (example B1 or A1 or A99)[/TD]

    [/tr]


    [tr]


    [/tr]


    [tr]


    [/tr]


    [tr]


    [/tr]


    [tr]


    [/tr]


    [tr]


    [/tr]


    [tr]


    [/tr]


    [/TABLE]

  • Re: Macro to help match and sort data


    Try this out.


    You'll need to alter some references to suit your data setup.


    Module Code:




    Class Module Code:



    Class Module was also reamed to OutputClass.

  • Re: Macro to help match and sort data


    Thank you very much for your help.


    I have just started to learn VBA and therefore would not understand how to play with your script.


    Can I kindly request if you can apply the macro in my attached workbook so that I can execute it?


    Really appreciate all your help.

  • Re: Macro to help match and sort data


    Unfortunately I do most of my help waiting for things to run while I'm in the office and the firewall will stop me downloading your file.


    Essentially you need to take the code in the first box, create a module in your VBA project and paste it into that.


    Then create a Class Module within your VBA project and paste the contents of the second box into there.


    Then on the sheet where the user makes the selection I've created a named range called "SelectionInput".


    The Sample data that the code needs to check through is a named range called "SampleList".


    After that it's just the sheet references.


    If that still doesn't make sense, perhaps someone else could download the file and paste the code in and post it back for you.

  • Re: Macro to help match and sort data


    Thank you very much for trying to help. I have done what you have instructed but it seems that I am not doing everything that is required to run the script, therefore generating errors.


    Would request someone to help me by adding the script to the excel file so that I can execute it.

Participate now!

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