Construct a string based on checked cells

Hoping there's a way in Excel to do this - see picture - I want each column to check for an "x" and if found, append a code at right to a cell at top.  Hopefully the picture is worth a 1000 words (or more).  Not sure what formula, if any can do this... Can vaguely see a VBA way but would rather avoid that.

LVL 99
Lee W, MVPTechnology and Business Process AdvisorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gerwin Jansen, EE MVETopic Advisor Commented:
What you are looking for is a concatif function, that checks for non empty values and then concatenates (with an additional semicolon) to the string you want.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
Great, thanks, I'll check it out.
It's possible but it wouldn't be very pretty without some VBA code:Capture.JPGTo explain, the 'G' column becomes your temporary holder for 'C' column values, 'H' for 'D'; etc. etc.
Once you have these values then you can concatenate the holder values -Capture.JPGPersonally, I would use a Function to do all this work for me.  If you want I can whip one up.

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Nevermind on whipping one up, Gerwin's posted PAQ does this nicely. ;)

Gerwin's posted EE PAQ in action:Capture.JPGRepost of code used from http:/Q_26884303.html -
' Credit to Rory Archibald;
' EE PAQ -
Function CONCATENATEIF(Source As Range, Criteria, Target As Range, Optional Delimeter As String = ", ")
    Dim fSource, fTarget
    Dim fRow As Long, fColumn As Long
    If (Source.Rows.Count <> Target.Rows.Count) Or (Source.Columns.Count <> Target.Columns.Count) Then
        CONCATENATEIF = CVErr(xlErrRef)
        fSource = Source.Value
        fTarget = Target.Value
        For fRow = LBound(fSource, 1) To UBound(fSource, 1)
            For fColumn = LBound(fSource, 2) To UBound(fSource, 2)
                If StrComp(fSource(fRow, fColumn), Criteria, vbTextCompare) = 0 Then
                    CONCATENATEIF = CONCATENATEIF & Delimeter & fTarget(fRow, fColumn)
                End If
            Next fColumn
        Next fRow
        If Len(CONCATENATEIF) > 0 Then
            CONCATENATEIF = Mid$(CONCATENATEIF, Len(Delimeter) + 1)
            CONCATENATEIF = ""
        End If
    End If
End Function

Open in new window

Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
To be clear for others, you have to open the VBA editor, add a new module, and paste the function code from the PAQ in there.  Then it works great.

Gerwin Jansen, EE MVETopic Advisor Commented:
You're welcome ;)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.