简体   繁体   English

如果单元格在标题下方显示“是”,则Excel 2在工作表2中返回标题。 并将其插入工作表1

[英]Excel 2016 Return Header in Sheet 2 if Cell says “Yes” below the header. And insert it in Sheet 1

I have a List of people in sheet 1, and they have Skills as column, for example Languages(Lang): 我在工作表1中有一个人员列表,他们的技能列,例如Languages(Lang):

  Lang Skill2 Skill3
P1  x    x       x
P2  x    x       x 
P3  x    x       x

In Sheet 2 I have the Matrix for that particular skill and the Persons in rows (P1,P2,P3), and all the columns for the Languages (L1, L2, L3) just say "Yes" and "No" 在工作表2中,我具有该特定技能的矩阵,并且行中有“人”(P1,P2,P3),语言的所有列(L1,L2,L3)都说“是”和“否”

  L1 L2 L3
P1 y  n  n
P2 y  y  n
P3 y  n  y

Now My goal is to Return the Header (L1) in sheet 2 if it says "Yes" in a below Cell for that particular Person. 现在,我的目标是,如果该特定人员在下面的单元格中说“是”,则返回工作表2中的标题(L1)。 And Input that header in a List or just as a string of text separated by commas (,) in Sheet 1. 然后在工作表1中将该标题输入到列表中,或作为由逗号(,)分隔的文本字符串输入。

I want to make it as cleanly as possible, and I have been trying for days to come up with an formula. 我想使其尽可能整洁,而且我已经尝试了数天来提出一个公式。 Unfortunately, unsuccessful so far. 不幸的是,到目前为止没有成功。

Are you able to help me with this problem? 您能帮我解决这个问题吗?

I am up for nearly anything at this point, even using VBA (if necessary). 在这一点上,我几乎可以解决所有问题,即使使用VBA(如有必要)也是如此。 Also Both tables are Formatted tables. 另外,两个表都是带格式的表。 If that is necessary to know. 如果有必要知道的话。

Thank you in advance. 先感谢您。

I would recommend you to use following formula. 我建议您使用以下公式。

=IF(Sheet2!B2="y";Sheet2!B$1&", ";"")&IF(Sheet2!C2="y";Sheet2!C$1&", ";"")&IF(Sheet2!D2="y";Sheet2!D$1&", ";"")

You just add a new IF condition for an additional language. 您只需为其他语言添加新的IF条件即可。 You can also add new formulas for a new skills with another data source. 您还可以使用其他数据源为新技能添加新公式。

The LEFT function cuts off the space and comma separator behind last skill. LEFT功能可切断最后一个技巧后面的空格和逗号分隔符。 But if person speaks no language then it would cause an error. 但是,如果某人不说任何语言,则将导致错误。 But you can update the formula in a following way 但是您可以通过以下方式更新公式

=IF(COUNTIF(Sheet2!B2:D2;"y")>0; LEFT(IF(Sheet2!B2="y";Sheet2!B$1&", ";"")&IF(Sheet2!C2="y";Sheet2!C$1&", ";"")&IF(Sheet2!D2="y";Sheet2!D$1&", ";"");LEN(IF(Sheet2!B2="y";Sheet2!B$1&", ";"")&IF(Sheet2!C2="y";Sheet2!C$1&", ";"")&IF(Sheet2!D2="y";Sheet2!D$1&", ";""))-2);"")

Then the cell is left blank in case person has no skill. 然后,如果人没有技能,该单元格将留空。

Plese look at my example sheet where you can see an example output for your data. 请看我的示例表 ,您可以在其中看到数据的示例输出。

Edit #1 编辑#1

I did not realize that for US language settings there is a comma as a default list separator. 我没有意识到,对于美国语言设置,逗号作为默认列表分隔符。 So the updated formula for default US locale is this one: 因此,默认美国区域设置的更新公式为:

=IF(COUNTIF(Sheet2!B2:D2,"y")>0, LEFT(IF(Sheet2!B2="y",Sheet2!B$1&", ","")&IF(Sheet2!C2="y",Sheet2!C$1&", ","")&IF(Sheet2!D2="y",Sheet2!D$1&", ",""),LEN(IF(Sheet2!B2="y",Sheet2!B$1&", ","")&IF(Sheet2!C2="y",Sheet2!C$1&", ","")&IF(Sheet2!D2="y",Sheet2!D$1&", ",""))-2),"")

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

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