Returning column header of furthest right example of specific text string.

hc1904

New Member
Joined
Nov 4, 2019
Messages
3
Hi,
Forum newbie here, this site has helped me many times as I've always found that my query has been asked and answered before but not this time hence my first time post.

So hello! and I hope someone can help on a puzzle that is beyond my Excel knowledge, hopefully I can explain it correctly.

I have the data on sheet1 as below.
ABCDEFG
1Email Step A1Step A2Step A3Step B1Step B2Step B3
2email1completedenrolledenrolledenrolledenrolledenrolled
3email2completedcompletedcompletedcompletedcompletedenrolled
4email3completedcompletedcompletedenrolledenrolledenrolled

<tbody>
</tbody>

On sheet2 I need to first look up the email address and then return the column header of the furthest right example of the text string "completed" like below.
AB
1Email Last Step Completed
2email1Answer would be "Step A1"
3email2Answer would be "Step B2"
4email3Answer would be "Step A3"

<tbody>
</tbody>

Hopefully that makes sense, I appreciate any help on this.
Thanks
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
This formula will get the job done. It's a combination of a SUMPRODUCT() function to determine which column as the word COMPLETED in it. That function is nested inside an INDEX() function to get your result. The sheet names are Sheet1 for your original data, and Sheet2 for the results sheet. You can rename the sheets to make the formulas more readable... Also, it assumes your original table on Sheet1 starts at A1, and the words email1 on Sheet2 starts again on cell A1.

=INDEX(Sheet1!$B$1:$G$1,0,SUMPRODUCT((A1=Sheet1!$A$2:$A$4)*(Sheet1!$B2:$G2="Completed")))

Good luck...
 
Upvote 0
That is wonderful, thanks so much!

I need to learn more about SUMPRODUCT as it's not something I've used much, thanks again.
 
Upvote 0
Heres a way that doesnt need the same caveats:

=LOOKUP(2,1/(INDEX(Sheet1!$B$2:$G$4,MATCH(A2,Sheet1!$A$2:$A$4,0),0)="completed"),Sheet1!$B$1:$G$1)
 
Upvote 0
Brilliant, thank you - after playing around with the data the original solution would not have worked as my data wouldn't always meet the proposed criteria. Your version however works regardless of which row the email data is on, perfect!
 
Upvote 0
Hi @hc1904, welcome to the forum!

The correct formula for sumproduct, could be


=INDEX(Sheet1!$B$1:$G$1,0,SUMPRODUCT(MAX((Sheet1!$A$2:$A$4=A2)*(Sheet1!$B$2:$G$4="Completed")*(COLUMN(Sheet1!$B$1:$G$1))))-1)



But I like Steve's formula, it's shorter.
 
Upvote 0
I found the detail of the formula of @bbotzong, it should be like this:


=INDEX(Sheet1!$B$1:$G$1,0,SUMPRODUCT((A2=Sheet1!$A$2:$A$4)*(Sheet1!$B$2:$G$4="Completed")))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,707
Members
448,981
Latest member
recon11bucks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top