简体   繁体   中英

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

I have an Excel sheet in the following format:

在此处输入图像描述

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? 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_B being all data in column Type_B;
  • Type_C being all data in column Type_C;
  • Cat_1 being all data in column Category_1;
  • Cat_2 being all data in column 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):

=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.

TEXTJOIN function is only available in Excel 365 and later versions.

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. 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.

Let me know if you have any questions. Cheers:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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