简体   繁体   English

在数据中添加新的列和行时,Excel自动更新图形

[英]Excel automatically update graph when adding new columns and rows in data

折线图和源表

My excel graph comes from a table in another sheet, as shown in the above image. 我的excel图形来自另一个工作表中的表格,如上图所示。

The X-axis of the graph shows the month/year headers in blue in row 3 except column A&B (.... 43.july17, 44.aug17, ...). 图的X轴在第3行中以蓝色显示月份/年份标题,但A&B列除外(.... 43.july17,44.aug17,...)。

The Y axis shows the Ave. Y轴显示Ave。 subs length in row 57 except column A&B. 排除了第5​​7行中As和B列之外的其他内容的长度

Every month I need to insert a new month/year column, in this case between column AY and AZ. 每个月我都需要在AY和AZ列之间插入一个新的month / year列。 I also need to insert new monthly row data, in this case under Month 14 in row 17, so that the Ave. 我还需要插入新的每月行数据,在这种情况下,请在第17个月的第14个月下插入Ave。 Subs length row is moving 1 row down every month. 订阅者人数行每月向下移动1行。

Data under the TOTALS column (AZ) are not included in the graph. TOTALS列(AZ)下的数据不包括在图形中。 I currently use the graph formula: 我目前使用图形公式:

=SERIES(,'Cohorts(32015)'!$C$3:$AX$3,'Cohorts(32015)'!$C$57:$AX$57,1)

However, it does not automatically update when I add new columns to the table. 但是,当我向表中添加新列时,它不会自动更新。 Is there a way to do this? 有没有办法做到这一点?

Yes it is :). 是的 :)。

There is a function in Excel called "Name Manager". Excel中有一个名为“名称管理器”的函数。 There you can define ranges (name a range or a cell/cells) and therefore make ranges dynamic as you insert or delete columns or rows. 您可以在此处定义范围(命名范围或一个或多个单元格),并因此在插入或删除列或行时使范围动态化。

Guide: 指南:

Go to "Formulas" -> "Defined Names" -> "New.." 转到“公式”->“定义的名称”->“新建”。

在此处输入图片说明

I create two ranges (notice I use absolute reference with $ ). 我创建了两个范围(注意,我在$中使用了绝对引用 )。

在此处输入图片说明

1 - The first one is for the axis values (43.july17, 44.aug17 etc..). 1-第一个用于轴值(43.july17、44.aug17等)。 I call it " Month_Name ". 我称之为“ Month_Name ”。 Notice you need to do it from $C$3 given your example. 请注意,根据您的示例,您需要从$C$3

=OFFSET(Sheet1!$AS$3,0,0,1,COUNTA(Sheet1!$AS$3:$AZ$3)-1)

2- The second one is for your data range (Ave. subs length). 2-第二个是您的数据范围(平均子长度)。 I call the range: " Ave_Sub ". 我将范围称为“ Ave_Sub ”。

=OFFSET(Sheet1!$AS$57,0,0,1,COUNTA(Sheet1!$AS$57:$AZ$57)-1)

Click on your series (in your graph/chart) and change your series names to the sheet name + named range ie in my case the sheet name is "Sheet1": 单击您的系列(在图形/图表中),然后将系列名称更改为图纸名称+命名范围,即在我的情况下,图纸名称为“ Sheet1”:

=SERIES(;Sheet1!Month_Name;Sheet1!Ave_Sub;1)

在此处输入图片说明

When you add rows or columns now, the graph will automatically expand (I added 1 row and one column). 现在添加行或列时,图形将自动展开(我添加了1行和1列)。

在此处输入图片说明



Details about formula: 有关公式的详细信息:

So how does it work? 那么它是怎样工作的?

Syntax for the formula is: 该公式的语法为:

=OFFSET(reference, rows, cols, [height], [width])

and in our case 在我们的情况下

=OFFSET(Sheet1!$AS$3,0,0,1,COUNTA(Sheet1!$AS$3:$AZ$3)-1)

Where: 哪里:

reference : is our start column, $AS$3 . reference :是我们的起始列$AS$3

rows and cols : We don't want to offset any column or rows. rowscols :我们不希望抵消任何列或行。 Therefore: 0,0. 因此:0,0。

[height] : = 1 since we have one row. [height] := 1,因为我们只有一行。

[width] = COUNTA(Sheet1!$AS$3:$AZ$3)-1 , we take the first column we want to have in our chart and the last column in the range we possible want to add or delete a column. [width] = COUNTA(Sheet1!$AS$3:$AZ$3)-1 ,我们采用想要在图表中拥有的第一列,并获得了可能要添加或删除列的范围中最后一列。 In our case the "Total" will be our last column. 在我们的案例中,“总计”将是我们的最后一列。 But we don't want "Total" to appear therefore we take -1 in our range. 但是我们不希望出现“总计”,因此我们在范围内取-1

Generic formulas to expand ranges : 扩展范围的通用公式

For columns: 对于列:

=OFFSET(<sheet name="">!<start cell="">,0,0,1,COUNTA(<sheet name="">!<column name="">:<column name="">) - 1)

For rows: 对于行:

=OFFSET(<Sheet name>!<start cell>,0,0,COUNTA(<Sheet name>!<Column name>:<Column name>) - 1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM