+ Reply to Thread
Results 1 to 10 of 10

Index & Match Formula & MACRO

  1. #1
    Registered User
    Join Date
    06-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 365
    Posts
    85

    Index & Match Formula & MACRO

    I have created a macro that uses a pivot table to extract the a list of reference numbers from a weekly information sheet containing data for the whole country. I use the formula below to match the clients reference numbers within the weekly M.I with the numbers that are relevant to my region. The formula i used is shown below.

    =INDEX(PO!A:A,MATCH(Sheet1!A:A,PO!A:A,0))


    The problem I'm having is when I receive the new weekly information, I run the Macro and a new pivot table is created in a new sheet. However the formula doesn't recognise that a new sheet has been created. Basically I need the "Sheet1!A:A" part of the formula to be relevant to the new data created by the pivot table every time I run the macro.

    Can anyone help please?
    Last edited by Harry Basra; 06-11-2013 at 04:17 PM.

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Index & Match Formula & MACRO

    Hi Harry,


    welcome to the forum.

    Sheet1:A:A - this column A will have new data appended at the bottom everytime you run the macro and you want this new data to be considered in formula... correct? If so, can you upload a sample workbook so that I can try a quick attempt ? Thanks


    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Registered User
    Join Date
    06-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 365
    Posts
    85

    Re: Index & Match Formula & MACRO

    Hi DILIPandey

    Thank You very much for your response. Yes you're right in thinking that every time I run the macro I want this new data to be considered in formula. I am currently unable to uploaded a sample at the current time due to restrictions at work. However I will get one uploaded towards the end of the day when I am home.

    Thank You

    Harry

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Index & Match Formula & MACRO

    Okay... no problem.

    Looking forward to the sample...



    Regards,
    DILIPandey
    <click on below * if this helps>

  5. #5
    Registered User
    Join Date
    06-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 365
    Posts
    85

    Re: Index & Match Formula & MACRO

    Book1.xls

    Hi


    I have uploaded a sample. The data has obviously been cut down a lot just to make it easier to decipher. You will find i haveincluded a comment in cell G8 of sheet 1. I hope this helps

    Thank

    Harry

  6. #6
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Index & Match Formula & MACRO

    Okay... I have updated your macro.. try again

    Book1.xls

    Regards,
    DILIPandey
    <click on below * if this helps>

  7. #7
    Registered User
    Join Date
    06-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 365
    Posts
    85

    Re: Index & Match Formula & MACRO

    Thank you very much for this. I cant look at it until I'm home afraid due to restrictions at work. What exactly have you done, as I am going to have to apply it to the main workbook saved on my work drive?

    Thank You

  8. #8
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Index & Match Formula & MACRO

    I have edited your existing macro a little bit.

    removed code line in beginning before ActiveWorkbook.PivotCaches.....
    and updated below line:-
    ActiveCell.FormulaR1C1 = _
    "=INDEX('Order Numbers'!C[-4],MATCH(C[-2],'Order Numbers'!C[-4],0))"

    thats it

    Regards,
    DILIPandey
    <click on below * if this helps>

  9. #9
    Registered User
    Join Date
    06-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 365
    Posts
    85

    Re: Index & Match Formula & MACRO

    Thank you very much for you help DILIPandey

  10. #10
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Index & Match Formula & MACRO

    you are welcome Harry Basra

    Please mark this thread as [SOLVED].. thanks.


    Regards,
    DILIPandey
    <click on below * if this helps>

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1