Returning header labels based on cell values

sam aljanabi

New Member
Joined
Jul 24, 2017
Messages
2
Hi ,
I need your help, i have a sheet that has several entries (columns and row, sample below) i would like to retrieve the header label based on a certain cell value (i.e. pending) and place the labels in the last cell (who is pending).
in other words, if there is a date in the cell then its ok otherwise raise a flag and point out that the ticket number for that individual is still pending and that ticket is not complete.

The output in the last cell should be as follows:
- First ticket [PETER, DAVID]
- Second ticket [SAM]
- Third ticket [ jack, peter, mark]
- Last ticket [ALL COMPLETE]


ticket numberSAMJACKPETERDAVIDMARKWho is pending
12345612-10-20162-5-2014pendingpending3-5-2015
123457pending2-8-20152-9-20152-6-20175-9-2.014
1234582-7-2011pendingpendingpendingpending
12345910-2-20154-9-20167-8-20147-5-20137-3-2017

<tbody>
</tbody>


Thanks
Sam
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hello,

is this oK (in first who is pending cell)

=IF(B2="pending",B$1,"")&IF(C2="pending"," "&C$1,"")&IF(D2="pending"," "&D$1,"")&IF(E2="pending"," "&E$1,"")&IF(F2="pending"," "&F$1,"")

and copy down
 
Upvote 0
Hello,

If your data has a lot of columns, which would make the IF formula length you could use VBA

Code:
Sub PENDING()
    For MY_ROWS = 2 To Range("A" & Rows.Count).End(xlUp).Row
        For MY_COLS = 2 To Cells(1, Columns.Count).End(xlToLeft).Column - 1
            If Cells(MY_ROWS, MY_COLS).Value = "pending" Then
                MY_COUNT = MY_COUNT + 1
                MY_NAMES = MY_NAMES & " " & Cells(1, MY_COLS).Value
            End If
        Next MY_COLS
        If MY_COUNT = 0 Then
            Cells(MY_ROWS, Columns.Count).End(xlToLeft).Offset(0, 1).Value = "ALL COMPLETE"
        Else
            Cells(MY_ROWS, Columns.Count).End(xlToLeft).Offset(0, 1).Value = MY_NAMES
        End If
        MY_NAMES = ""
        MY_COUNT = 0
    Next MY_ROWS
End Sub

Have assumed your data starts in Cell A1
 
Upvote 0
Hello,
thanks for feedback, the first post worked fine, but i do have roughly 20 columns, and i am not that keen in VBA.
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,289
Members
448,885
Latest member
LokiSonic

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