Excel chart dynamic range-selection

后端 未结 2 1210
星月不相逢
星月不相逢 2021-01-15 13:02

I have a client that has a simple yet complicated request for an excel sheet setup, and I can\'t for the world thing of where to start. I\'m drawing a blank.

We have

相关标签:
2条回答
  • 2021-01-15 13:31

    I know this is an old question, but I wanted to share an alternative that may be easier.

    Change your Quarter-Data range to an Excel Table. Select the range, and press Ctrl+T. In the Insert Table, make sure the correct data range is selected, and that My Table Has Headers is checked, and press OK. This converts the simple range into a special data structure with magical properties.

    Then make a new range which links to the last four rows of this table, and create a chart based on this new range. This is illustrated below. The table is the specially formatted range in A1:B9 (you can choose a less in-your-face style), and the plotting range is D1:E5.

    The formulas in cells D2 through D5 are below. Copy D2:D5 and paste into E2:E5 to complete the formulas in our plotting range.

    D2: =INDEX(Table1[Quarter],ROWS(Table1[Quarter])-3) D3: =INDEX(Table1[Quarter],ROWS(Table1[Quarter])-2) D4: =INDEX(Table1[Quarter],ROWS(Table1[Quarter])-1) D5: =INDEX(Table1[Quarter],ROWS(Table1[Quarter]))

    Table1 is the name assigned to the Table, and Quarter is the name of the first column of the Table (and also the column header). You don't need to type all this, just select the column in the Table. As the Table expands or contracts, Table1[Quarter] keeps track of the changes.

    Now add a new data point. The Table expands, and our little staging area in D1:E5 links to the new last four rows of the table.

    And as we add years worth of data, the formulas and the chart keep up.

    0 讨论(0)
  • 2021-01-15 13:47

    If the chart is on the same sheet as the data:

    Name the first cell of the data (A2) as a named range, say TESTRANGE. Created a named range MYDATA as the following formula:

    =OFFSET(TESTRANGE, COUNTA($A:$A) - 5, 0, 4, 2)
    

    Now, go to the SERIES tab of the chart SOURCE DATA dialog, and change your VALUES statement to:

    =Sheet1!MYDATA
    

    Now everytime you add a new row, it'll change the chart.

    0 讨论(0)
提交回复
热议问题