简体   繁体   中英

Set a range in Excel based on values of corresponding cells

I have 2 columns in Excel, like this:

Col1 Col2

A 1

B 2

C 4

C 1

A 13

B 5

I need to generate 3 ranges in excel containing the values in Col2 , based on the distinct values of Col1. Thus: Name Range A will have values 1,13 Name Range B will have values 2,5 Name Range C will have values 1,4

How can I do it?

Enter the following formula in Cell D2

=IFERROR(INDEX($B$2:$B$17, MATCH(0, IF(D$1=$A$2:$A$17, COUNTIF(D$1:D1, $B$2:$B$17), ""), 0)),"")

Drag/Copy down and across as required.

This is an array formula so commit it by pressing Ctrl + Shift + Enter . See image for reference.

在此处输入图片说明

EDIT:________________________________

Try this:

=IFERROR(INDEX($B$2:$B$18, SMALL(IF(D$1=$A$2:$A$18, ROW($A$2:$A$18)-1, ""), ROW(A1))),"")

Again this is an array formula.

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