Here is a user-defined function (UDF) that will do what you want, and if you know VBA is simple to update.
The function takes as input the cell that can be X or Y. This will cause it to recalculate when that cells changes, so avoids requiring this to be a volatile function. However that means it will not automatically recalculate if the cells in B, C, D, or E change.
Code below, example attached.
Option Explicit
Public Function CondConcat(TestCell As Range) As String
With TestCell.Parent
Select Case TestCell
Case "X"
CondConcat = .Cells(TestCell.Row, "B") & "in, " & .Cells(TestCell.Row, "C") & ", " & .Cells(TestCell.Row, "D")
Case "Y"
CondConcat = .Cells(TestCell.Row, "B") & "in, " & .Cells(TestCell.Row, "C") & ", " & .Cells(TestCell.Row, "E")
End Select
End With
End Function
Bookmarks