Display an excel table/matrix as a list using form

2019-08-03 15:13发布

问题:

This is a follow-on to my previous question here, as i think it merits its own exploration.

My source data is organized with locations as column headings (B1:E1), and events as row headings (A2:A50). The remaining cells (B2:E50) are populated with dates representing when the next event at each location will be held. Not all locations serve each event, so "N/A"s are possible. events may be held at the same location on the same day.

In the previous answer, I learned how to display events as separate lists under each location, sorted by date. for this exercise, I wish to consolidate all events into a single list consisting of three columns (date, event, location), sorted in that order, and do so using formula. As in the previous exercise, pivot tables are out of the question.

Source data:

   A                    B               C           D               E
1                       San Francisco   Tampa       Philadelphia    Houston
...
6   Introduction        7-Feb-15        24-Jan-15   17-Jan-15       10-Jan-15
7   Beginner I          9-Feb-15        26-Jan-15   19-Jan-15       12-Jan-15
8   Beginner II         23-Feb-15       9-Feb-15    2-Feb-15        26-Jan-15
9   Beginner III        9-Mar-15        23-Feb-15   16-Feb-15       9-Feb-15
10  Intermediate I      16-Mar-15       19-Jan-15   N/A             19-Jan-15
11  Intermediate II     12-Jan-15       2-Feb-15    N/A             2-Feb-15
12  Intermediate III    26-Jan-15       16-Feb-15   N/A             16-Feb-15
13  Advanced I          9-Feb-15        N/A         N/A             2-Mar-15
14  Advanced II         23-Feb-15       N/A         N/A             16-Mar-15
15  Advanced III        9-Mar-15        N/A         N/A             30-Mar-15

desired output:

January     
10-Jan-15   Introduction        Houston
12-Jan-15   Beginner I          Houston
12-Jan-15   Intermediate II     San Francisco
17-Jan-15   Introduction        Philadelphia
19-Jan-15   Beginner I          Philadelphia
19-Jan-15   Intermediate I      Houston
19-Jan-15   Intermediate I      Tampa
24-Jan-15   Introduction        Tampa
26-Jan-15   Beginner I          Tampa
26-Jan-15   Beginner II         Houston
26-Jan-15   Intermediate III    San Francisco

回答1:

You can get the date list in almost the same way as before because the formula doesn't care if the source is a single column or a matrix, so with 1st of the month in cell A1 in your "summary" worksheet you can start with this array formula in A3

=IFERROR(SMALL(IF(Master!B$2:E$50>=A$1,IF(Master!B$2:E$50< EOMONTH(A$1,0)+1,Master!B$2:E$50)),ROWS(A$3:A3)),"")

Then it's probably easier next to get the cities, so in C3

=IF(A3="","",INDEX(Master!B$1:E$1,SMALL(IF(Master!B$2:E$50=A3,COLUMN(Master!B$2:E$50)-COLUMN(Master!B$2)+1),COUNTIF(A$3:A3,A3))))

Then in B3 for the text

=IF(A3="","",INDEX(Master!A$2:A$50,SMALL(IF(INDEX(Master!B$2:E$50,0,MATCH(C3,Master!B$1:E$1,0))=A3,ROW(Master!A$2:A$50)-ROW(Master!A$2)+1),COUNTIFS(A$3:A3,A3,C$3:C3,C3))))

All formulas need to be confirmed with CTRL+SHIFT+ENTER and copied down the columns as far as you need