How to use automatically update formula without dragging

£可爱£侵袭症+ 提交于 2021-02-08 08:57:17

问题


I have a table in Sheet1 that looks like this

**Sport**
Basketball
Basketball
Basketball
Volleyball
Volleyball
Football
Football
Football
Football
Football
Football
Hockey
Hockey
Hockey

I have a table in Sheet2 that looks like:

SPORT   Basketball  Volleyball  Football    Hockey
SCORE       3           2          6           3

I applied the following formula in B1:

=TRANSPOSE(UNIQUE(FILTER(Sheet1!$A$2:$A$15,Sheet1!$A$2:$A$15<>"")))

formula in B2:

=COUNTIF(Sheet1!$A$2:$B$15,Sheet2!B1)

However when the column in Sheet1 is updated. For example, changing one of the hockey fields to Golf, this is updated in the HEADER but the formula and formatting below is not carried across WITHOUT having to physically drag it across.

SPORT   Basketball  Volleyball  Football    Hockey    Golf
SCORE       3           2          6           3

As you can see the score for Gold is empty.... I need this to be filled automatically. Is there a way that I can have excel automatically "pull" the formula that is contiguous in the column into the added row?

(Simplified data and formula for ease of understanding!!)


回答1:


Use the spilled range operator # to reference the entire spilled range:

=COUNTIF(Sheet1!$A$2:$B$15,B1#)




回答2:


Alternatively you may try to use a single formula in B1:

=LET(X,TRANSPOSE(UNIQUE(FILTER(Sheet1!A:A,(ROW(Sheet1!A:A)>1)*(Sheet1!A:A<>"")))),CHOOSE({1,2},X,COUNTIF(Sheet1!A:B,X)))


来源:https://stackoverflow.com/questions/65739210/how-to-use-automatically-update-formula-without-dragging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!