0
votes

I have an Excel worksheet (Sheet 1) with a list of People's named and their responsible training groups... basically numbers assigned to different handlers.

I need to:

On Sheet 2, I need an IF statement that checks Sheet 1, Column B and if a certain person's name appears, it returns the value to the immediate left.

I have something like this on Sheet 1:

Group Name
101 Fred
102 Wilma
103 Fred
104 Fred
105 Barney
106 Wilma

On Sheet 2, I need this:

Barney Fred Wilma
105      101   102
     &nbsp     &nbsp103   106
           &nbsp104

The equation I am trying to use in each cell on sheet 2 is"

=IF('Sheet 1'!B:B="Barney",relative position one cell to the left of name,"")

Thanks in advance.

1
Looks like you're trying to do a VLOOKUPhsan
You'll need an array formula. Have you tried anything? @hsan - VLOOKUP will only return the first result.SJR
I tried to use the VLOOKUP but I couldn't figure it out. I will try the array. I am a complete novice so it takes me time to learn each thing.Jeremy

1 Answers

0
votes

No array formula needed:

MINIFS($A$2:$A$7,$B$2:$B$7,D$1,$A$2:$A$7,">" & MAX(D$1:D1))

Just a simple MINIFS. Then wrap it in an IF to remove the zeros:

enter image description here

EDIT: Further clarification in response to comment.

I have put both tables on the same sheet for ease, however, one could easily be moved onto a separate sheet if needed.

The formula works by selecting the group with the lowest value, which has the name which appears at the top of the column AND which has not already been listed.

So:

MINIFS($A$2:$A$7,$B$2:$B$7,D$1,$A$2:$A$7,">" & MAX(D$1:D1))

The first argument in the MINIFS formula is $A$2:$A$7. This is the column containing all the groups, which we want to split out and list against each name.

The 2nd and 3rd argument ($B$2:$B$7,D$1) is a criteria range and it's value. This is used to filter out any name we dont want to return in this particular cell (any that are not "Barney" in the case of D2). Notice that the D$1 in the formula does not start with a $, this means that we can just drag the formula across the other name columns and it will filter out the correct names automatically.

The 4th and 5th Arguments ($A$2:$A$7,">" & MAX(D$1:D1)) are also a criteria range and its value. Howevever, in the case of the value this time, we are looking for the max value within a range. We are looking at all the groups which have already been listed against a name and using MAX to select the highest one.Notice that there is a $ before the first "1" in the formula but not before the second. This means that as we drag the formula down, the range that it is looking for the MAX in, will automatically expand to include the cell just above the current one. Also note that there is no $before either of the "D"s, this is so that when you drag the formula to the right, the range it is checking also moves to the right. Once we have the MAX group which has already been listed against a name, we tell the MINIFS formula to only look at groups which are greater than that.

Once there are no groups for a name which are greater than the previously listed group, the MINIFS formula will return 0. To prevent the table from showing lot's of 0's, we simply say "If the MINIFS formula returns 0, then return an empty string instead:

=IF(<the result of the MINIFS>=0, "",<the result of the MINIFS>)

So the final formula would be:

=IF(MINIFS($A$2:$A$7,$B$2:$B$7,D$1,$A$2:$A$7,">" & MAX(D$1:D1))=0,"",MINIFS($A$2:$A$7,$B$2:$B$7,D$1,$A$2:$A$7,">" & MAX(D$1:D1)))

I hope that makes more sense for you. I am sorry if the explanation is a bit long winded, but as you didn't give me a specific area that you didn't understand, I just tried to expand my explanation generally. If there is any specific part you need me to explain further, please let me know.