简体   繁体   English

公式或宏可根据其值对单元格进行分组

[英]Formula or macro to group cells according to their values

I am on a spreadsheet that needs to retitle cells based on the cell value and the values of the cells below it. 我正在使用一个电子表格,该电子表格需要根据单元格值及其下面单元格的值来对单元格重新命名。 Basically I have the below column, which is filled by a formula that links to another spreadsheet. 基本上,我有下面的列,该列由链接到另一个电子表格的公式填充。

Column A
EE
EE
SP
EE
CH
CH
EE
SP
CH
CH
EE
  • For an cell that has EE , and for which the cell below it is EE , then the first cell should read "EE Only". 对于具有EE且其下面的单元为EE的单元,则第一个单元应显示为“仅EE”。
  • For any cell that has EE , and for which the cell below it is SP , which is then followed by another EE , then the first two cells should read "EE+SP". 对于任何具有EE且其下面的单元格为SP的单元格,随后是另一个EE ,则前两个单元格应显示为“ EE + SP”。
  • For any cell EE where the cell(s) below it are CH , then those cells should read "EE+CH". 对于其下一个单元格为CH任何单元格EE ,则这些单元格应显示为“ EE + CH”。
  • And for any cell EE where the cells below it are SP and CH , then all of those cells should read "EE+FAM". 对于其下面的单元格是SPCH任何单元格EE ,则所有这些单元格都应显示为“ EE + FAM”。

The above column should then look like: 上面的列应如下所示:

Column A
EE Only
EE+SP
EE+SP
EE+CH
EE+CH
EE+CH
EE+FAM
EE+FAM
EE+FAM
EE+FAM
EE Only

It's a long table of values, and quite honestly I'm not even sure what the best way to go about this is. 这是一长串的价值观,说实话,我什至不知道实现此目标的最佳方法是什么。

Do I need to create a table of values to lookup against, or is there a macro that would be able to handle this? 我是否需要创建一个值表来查找,还是有一个宏可以处理这个问题?

From your input example: 从您的输入示例中:

=IF(AND(A2<>"EE",B1="EE+FAM"),"EE+FAM",IF(AND(A2="EE",OR(A3="EE",A3="")),"EE Only",IF(OR(AND(A1="EE",A2="SP",A3="EE"),AND(A2="EE",A3="SP",A4="EE")),"EE+SP",IF(OR(A2="CH",A3="CH"),"EE+CH",IF(AND(A2="EE",A3<>"EE"),"EE+FAM","")))))  

should derive your output example. 应该导出您的输出示例。

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

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