days of week list challenge

mwc0914

New Member
Joined
Sep 24, 2015
Messages
40
Here is a bit a of a challenge...
Say I have some days of week marked in cells by an "X", and a cell where I am currently entering the days of service.
I am looking for a formula in days of service cell that examines the cells to its left for an "X", and derives a concatenated list of the correct days

Thanks

MonTueWedThuFriDays of Service
xxTuesday, Thursday

<tbody>
</tbody><colgroup><col><col><col><col><col><col></colgroup>
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Assuming, the headings are in A1:F1.

In F2

=IF(RIGHT(IF(A2="x","Monday, ","")&IF(B2="x","Tuesday, ","")&IF(C2="x","Wednesday, ","")&IF(D2="x","Thursday, ","")&IF(E2="x","Friday",""),2)=", ",LEFT(IF(A2="x","Monday, ","")&IF(B2="x","Tuesday, ","")&IF(C2="x","Wednesday, ","")&IF(D2="x","Thursday, ","")&IF(E2="x","Friday",""),LEN(IF(A2="x","Monday, ","")&IF(B2="x","Tuesday, ","")&IF(C2="x","Wednesday, ","")&IF(D2="x","Thursday, ","")&IF(E2="x","Friday",""))-2),IF(A2="x","Monday, ","")&IF(B2="x","Tuesday, ","")&IF(C2="x","Wednesday, ","")&IF(D2="x","Thursday, ","")&IF(E2="x","Friday",""))
 
Upvote 0
Here's a custom function if you'd like.

Code:
Function dConcat(iRng As Range) As StringDim AR()
Dim wDays()
Dim Result As String


wDays = Array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
AR = iRng.Value


For i = LBound(AR(), 2) To UBound(AR(), 2)
    If AR(1, i) = "x" Or AR(1, i) = "X" Then
        Result = Result & wDays(i - 1) & ", "
    End If
Next i


If Len(Result) > 0 Then
    Result = Left(Result, Len(Result) - 2)
    dConcat = Result
Else
    dConcat = ""
End If


End Function

The formula would look like

Code:
=dConcat(A2:E2)
 
Upvote 0
If you have Excel 2016 via Office 365, would this be any use?
It is an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}.


Book1
ABCDEF
1MonTueWedThuFriDays of Service
2xxTue, Thu
Concat Days
Cell Formulas
RangeFormula
F2{=TEXTJOIN(", ",TRUE,IF(A2:E2="x",A$1:E$1,""))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
If you have Excel 2016 via Office 365, ...
Otherwise possibly this?


Book1
ABCDEF
1MonTueWedThuFriDays of Service
2xxTue, Thu
Concat Days
Cell Formulas
RangeFormula
F2=SUBSTITUTE(TRIM(IF(A2="","",A$1)&IF(B2="",""," "&B$1)&IF(C2="",""," "&C$1)&IF(D2="",""," "&D$1)&IF(E2="",""," "&E$1))," ",", ")
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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