Index And Match Functions In Macro Code

  • Hi
    I want to write the following function using VBA code:


    =INDEX($H$1:$H$6,MATCH(A1,$G$1:$G$6,0))


    Code is given below




    After run above code I can get only H6 value in Col B for all rather than each corresponding value.I would appreciate to solve this problem
    [TABLE="border: 0, cellpadding: 0, cellspacing: 0"]

    [tr]


    [TD="width: 64"]A[/TD]
    [TD="width: 64"]B[/TD]
    [TD="width: 76"]C[/TD]
    [TD="width: 73"]D[/TD]
    [TD="width: 64"]E[/TD]
    [TD="width: 64"]F[/TD]
    [TD="width: 64"]G[/TD]
    [TD="width: 64"]H[/TD]

    [/tr]


    [tr]


    [TD="align: right"]1[/TD]

    [td]

    Nov-Dec

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [TD="width: 64"] [/TD]

    [td]

    1

    [/td]


    [td]

    Jan-Feb

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]2[/TD]

    [td]

    Nov-Dec

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    2

    [/td]


    [td]

    Mar-Apr

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]3[/TD]

    [td]

    Nov-Dec

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    3

    [/td]


    [td]

    May-Jun

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]4[/TD]

    [td]

    Nov-Dec

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    4

    [/td]


    [td]

    Jul-Aug

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]5[/TD]

    [td]

    Nov-Dec

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    5

    [/td]


    [td]

    Sep-Oct

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]6[/TD]

    [td]

    Nov-Dec

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    [/td]


    [td]

    6

    [/td]


    [td]

    Nov-Dec

    [/td]


    [/tr]


    [/TABLE]

    Thanks

  • Hard to see what you are doing, because your sample table of data didnt copy/paste (misalignment) very well


    Is this what you are trying to do?


    Ger

    Check out our new reputation system. Click on the Like button under the post!
    _______________________________________________

    [SIZE=8px]There are 10 types of people in the world. Those that understand Binary and those that dont.


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25...


    The BEST Lookup function of all time


    Dynamic Named Ranges are your bestest friend[/SIZE]
    _______________________________________________

  • Code Tags Added
    Your post does not comply with our Forum RULES. Use code tags around code.


    Posting code between

    Code

    tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.


    Highlight your code and click the # icon at the top of your post window.


    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)