I’m working on a project where users will be going through a list of ‘tests’ and checking off whether the test passed or failed. If the test fails, they check the ‘fail’ box in the second column and record notes as to why that test failed. The setup looks like this:
I need to program a macro so that when the user finishes the ‘tests’ and clicks the ‘Generate Report’ button, it compiles a summary of the failed tests and the associated notes on another worksheet, such as this:
Worksheet 2 – Summary of Failed Tests (Bottom Image)
I have a development background but am not familiar with the syntax for Excel macros. I’ve done a little digging around but figured I’d ask here first. Essentially I need to run a loop through all the cells in the ‘fail’ column. Everytime I hit a ‘true’ value, output the contents of the notes in the cell to the right of it and the name of the test two cells to the left onto the other worksheet. Let me know how you’d approach this and what type of function you’d you – I greatly appreciate your help!
UPDATE: ANSWER HERE:
I created 3 named ranges: tests, fails, and notes. It’s easy, just select the list of tests (excluding the header) and type tests in the address box. Named range created. Do the same for your Fails and your Notes.
Then, on page 2:
[A3]=INDEX(tests,MATCH(TRUE,fails,0))
[B3]=INDEX(notes,MATCH(TRUE,fails,0))
[A4]=IFERROR(INDEX(OFFSET(tests,MATCH(A3,tests,0),0),MATCH(TRUE,OFFSET(fails,MATCH(A3,tests,0),0),0)),"")
[B4]=IFERROR(INDEX(OFFSET(notes,MATCH(A3,tests,0),0),MATCH(TRUE,OFFSET(fails,MATCH(A3,tests,0),0),0)),"")
(copy A4 and B4 down as far as you need it.)
Run an autofilter for true values and then copy the visible cells to your new sheet. VBA code for that will go something like this:
Solution here:
I created 3 named ranges: tests, fails, and notes. It’s easy, just select the list of tests (excluding the header) and type tests in the address box. Named range created. Do the same for your Fails and your Notes.
Then, on page 2:
(copy A4 and B4 down as far as you need it.)