简体   繁体   English

我可以在 Excel 中没有 VBA 的情况下在一行的每个单元格上循环吗?

[英]Can I loop on each cell of a row without VBA in Excel?

I have an Excel sheet in the following format:我有一张 Excel 表格,格式如下:

在此处输入图像描述

I want to have a second tab that uses this data and generates a table in this format我想要第二个选项卡,它使用这些数据并以这种格式生成一个表格在此处输入图像描述

I was wondering if this can be done without VBA?我想知道这是否可以在没有 VBA 的情况下完成? if not, any idea how should I best approach it?如果没有,知道我应该如何最好地处理它吗?

Thanks谢谢

Suppose you have the following named ranges:假设您有以下命名范围:

  • Type_A being all data in column Type_A; Type_A为 Type_A 列中的所有数据;
  • Type_B being all data in column Type_B; Type_B为 Type_B 列中的所有数据;
  • Type_C being all data in column Type_C; Type_C为 Type_C 列中的所有数据;
  • Cat_1 being all data in column Category_1; Cat_1是 Category_1 列中的所有数据;
  • Cat_2 being all data in column Category_2; Cat_2是 Category_2 列中的所有数据;
  • Functions being all data in column Functions.函数是列函数中的所有数据。

结果

In cell B8 , enter the following array formula (which needs to be confirmed by pressing Ctrl+Shift+Enter on your keyboard upon finishing the formula in the formula bar):在单元格B8中,输入以下数组公式(需要在完成公式栏中的公式后按键盘上的Ctrl+Shift+Enter 确认):

=TEXTJOIN(CHAR(10),1,IF((INDIRECT(B$7)="X")*(INDIRECT($A8)="X"),Functions,""))

Then highlight the output table and click Wrap Text button under Home tab to display the outcome with line break within the cell.然后突出显示 output 表并单击Home选项卡下的Wrap Text按钮以在单元格内显示带有换行符的结果。

TEXTJOIN function is only available in Excel 365 and later versions. TEXTJOIN function 仅在 Excel 365 及更高版本中可用。

A tip here, you can highlight your source table (including headers) and press Ctrl+Shift+F3 on your key board to quickly set the column header (top row) as the name for each range.这里有一个提示,您可以突出显示源表(包括标题)并在键盘上按Ctrl+Shift+F3以快速将 header 列(顶行)设置为每个范围的名称 Then you just need to set up the first row and first column with all types and categories for your output table, and use the above formula to return the desired output.然后,您只需为您的 output 表设置所有类型和类别的第一行和第一列,并使用上面的公式返回所需的 output。

Let me know if you have any questions.如果您有任何问题,请告诉我。 Cheers:)干杯:)

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

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