简体   繁体   中英

Copy cell contents if another cell has specific value

I have a few rows of data that looks something like:

   A        B
10501234   Cage
10501235   Cage
10501236   Cage
10501237   Cage
16001234   VIP
16001235   VIP
16001236   VIP

I need a formula in another row to separate out the VIP's. I want, for instance, E12 to check Row B for the word "VIP", if found, copy the corresponding number from A. Then I need E13 to check the list again and return the second VIP, E14 to return the third, and so on, if any exist. The information changes every day, sometimes there will be no VIP's, sometimes there will be dozens, but they will always be grouped similar to my example, all the VIP's together.

Example Output:

   E
16001234
16001235
16001236

Thank you for any advice you can offer.

In E11:

=COUNTIF(B:B,"VIP")

This will give you the number of VIP.

In E12:E?? (if you think you'll have a max of 20 VIP, enter in 20 rows):

=IF(ROW(A1)<=$E$11,SMALL(IF($B$2:$B$8="VIP",$A$2:$A$8),ROW(A1)),"")

This needs to be entered with ctrl + shift + enter and will be shown with curly brackets around it like this: {=IF(ROW(A1)<=$E$11,SMALL(IF($B$2:$B$8="VIP",$A$2:$A$8),ROW(A1)),"")} -- you cannot enter these curly brackets by hand.

Note: this will only work if the ID in column A are numerical values (it will not work if they are letters)

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