Column lookup macro

  • Hi All


    Beginner in VBA and macros,


    Looking for a column lookup to export the values from one table to another table.


    Attaching the workbook for better understanding.


    - Anna

    Files

    • Test v1.xlsm

      (12.69 kB, downloaded 28 times, last: )
  • Hello Anna,


    See if this heads you in the right direction:-


    I've attached your sample workbook with the code implemented. The "Output" sheet is empty. Click on the "TEST ME" button to see how it works.


    I hope that this helps.


    Cheerio,

    vcoolio.


    Anna.xlsm

  • vcoolio this code works perfect.. Thanks a lot


    could you please explain the code how it works,


    Because the required output column order is this(1,2,3,4,5,6,7,8,9,10,11)


    In your code its specified as random order "Array(1, 2, 3, 10, 11, 12, 4, 5, 6, 7, 8)" and "column 9" header is missing (in the code).


    Additionally, is it possible to delimit and extract the data in output sheet?

    For eg..

    Input:-

    Column 10 has the below data

    1-2 Days Australia

    13-14 Days way Vietnam

    5-6


    Required Output:

    Col.8

    1-2

    13-14

    5-6


    Col.9

    Australia

    Vietnam

    <blank>


    alansidman


    Thanks for your reply..


    Is it possible to customize the order list? Because in the real data, Column headers will be in string..

  • Hello Anna,


    Column 9 is not included because, in your sample output, you have not included it (Coco).

    If you need it to be included, add 9 after the 8 in the array and change the resize value to 12.


    The array appears random but is in fact quite precise. You have asked that columns K, L and M (10, 11 &12 based on your data setout) in the Input sheet be placed in columns E, F and G in the Output sheet starting at B4. The positions of the columns in the array determines the positions in the Output sheet.


    I don't quite follow your last request so, seeing that your supplied sample is not truly indicative of your actual workbook and its data, please supply a new sample set out exactly the same as your actual workbook including the data within the columns (ensure that it is still dummy data).


    Cheerio,

    vcoolio.