+ Reply to Thread
Results 1 to 13 of 13

Need INDEX MATCH macro to loop step 6

  1. #1
    Registered User
    Join Date
    11-08-2011
    Location
    Indiana
    MS-Off Ver
    Excel 2007, 2010
    Posts
    14

    Need INDEX MATCH macro to loop step 6

    I have spent the last couple weeks writing several macros to speed up a report. I am stuck on the last part which is getting the final data.

    I created a INDEX and MATCH macro which does give me the correct data for my test data but I cannot figure out how to make it loop to fill the remaining employees. The macro compares dates on 2 sheets and for the matches, it offsets and adds the formula. This is the only way I could think of to give me the starting cells. I need the loop to step 6 but I cannot figure out how to modify my code to do so. I appreciate any help.

    Here is my macro...

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need INDEX MATCH macro to loop step 6

    Hi SCDE,

    Your routine just pastes the formula in the same place - try this instead:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Need INDEX MATCH macro to loop step 6

    Hi SCDE,

    I call your type a problem an Crosstab to Table. If you had your data in a normal table, you could do a lot more with it. See the attached where I've moved your original data to a new sheet and "fixed" it up a bit and then run my macro on it. Then done a Pivot on that data. See if this works for you.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    11-08-2011
    Location
    Indiana
    MS-Off Ver
    Excel 2007, 2010
    Posts
    14

    Re: Need INDEX MATCH macro to loop step 6

    xladept,

    Thanks for the help. I used the code on my actual test data of 1000 rows and it worked great. I did have another sheet of similar data that I did not include because I thought formulas would still be used and I could replace the old formula with the new in the code I receive from this site. I changed the columns to the new sheet but after it fills one column, I get a "run-time 91: Object variable or With block variable not set" error. I reattached the workbook with the missing sheet. Thanks again.

    Error at line:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-08-2011
    Location
    Indiana
    MS-Off Ver
    Excel 2007, 2010
    Posts
    14

    Re: Need INDEX MATCH macro to loop step 6

    MarvinP,

    Thanks for looking at this. I see where you are going and I like the idea but it will not work in this case. I have macros just to clean up the data the way it is. Also, this is for someone at work. She was manually looking at 100s of rows to enter the numbers by hand. The original report is so messed up that I had to create code to remove colored rows, duplicates, and merged cells just to name a few. With this code, the report can be done with all code. Now she can paste the data in and run the macro and be done. This will knock down a 3+ hour job to a simple click. Excel is great. Thanks again.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need INDEX MATCH macro to loop step 6

    Hi SCDE,

    I'll look at it anon

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Need INDEX MATCH macro to loop step 6

    Though xladept will tell you exactly what to change in the code, I have found that the on IP sheet, you have some dates those belong to year 2114 not 2014 i.e. 19/09/2114 instead of 19/09/2014 and that is causing error in the code. Either you correct the dates on col. A of IP sheet or if you have mentioned the correct dates which belong to 2114, you may replace a portion of existing code with the following code......
    Please Login or Register  to view this content.
    See if this helps.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  8. #8
    Registered User
    Join Date
    11-08-2011
    Location
    Indiana
    MS-Off Ver
    Excel 2007, 2010
    Posts
    14

    Re: Need INDEX MATCH macro to loop step 6

    sktneer,

    Nice catch on the incorrect year. I do not know if it was given to me this way or if I accidentally changed it myself. I knew the error was sometimes caused by not finding a match and with the year not showing, it was easy for me to miss. Thanks for the help.


    xladept,

    Thanks again for the code. I like this way compared to using formulas that I was before.

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Need INDEX MATCH macro to loop step 6

    You're welcome.

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need INDEX MATCH macro to loop step 6

    Hi SCDE,

    You're welcome and thanks for the rep!

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need INDEX MATCH macro to loop step 6

    My fix is a little different from sktneer's and it also ignores the bad dates:

    Please Login or Register  to view this content.
    Last edited by xladept; 10-26-2014 at 03:23 PM.

  12. #12
    Registered User
    Join Date
    11-08-2011
    Location
    Indiana
    MS-Off Ver
    Excel 2007, 2010
    Posts
    14

    Re: Need INDEX MATCH macro to loop step 6

    xladept,

    Thanks for taking the time to create that code. I tested it on my full data and it worked.

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need INDEX MATCH macro to loop step 6

    You're welcome and thanks for the rep!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Index Match.. One step away.
    By Kevin Stewart in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-13-2013, 04:12 PM
  2. [SOLVED] For step loop, need step size to change based on reference cell in row
    By Telperion in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-22-2013, 03:41 PM
  3. Index / Match / Vlookup Loop across 3 sheets
    By NewExcelUser in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-23-2009, 03:27 AM
  4. Taking an Index Match Function one step further!
    By Ben Morton in forum Excel General
    Replies: 2
    Last Post: 04-08-2009, 07:17 AM
  5. Index and Match - the next step
    By MoonWeazel in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-27-2005, 01:05 PM

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