Avatar of jhoekman
jhoekman
Flag for United States of America asked on

Adding Quotes ("") Before and After Keyword in Cell

Hey experts!  

I am trying to take a keyword phrase that I have in one cell and automatically add quotes to before and after the phrase in a new cell.  So, what would start as ' keyword example ' in one cell would become ' "keyword example" ' in another.  

Ideas?
Microsoft Excel

Avatar of undefined
Last Comment
jhoekman

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
byundt

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Saqib Husain

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jhoekman

ASKER
Two correct answers in 3 minutes... you Excel gurus are amazing!  

Funny thing, I had tried the almost correct code, just with 3 " in a row, rather than 4.  

Thanks a bunch!
byundt

Or you may find it less confusing to use the ASCII character code:
=CHAR(34) & A2 & CHAR(34)

I don't know your ultimate aim, but you might be trying to build a SQL Query. If so, I have a function that lets you build a result string like: "Cat", "Dog", "Hoekman"
You call it with a formula like:
="""" & SQLbuilder(IV2:IV4,"",A2:A4,""", """,FALSE) & """"             'Concatenate the keywords in A2:A4.  Cells IV2:IV4 are assumed to be blank.

The function actually lets you look for a match in a different column. For example, if you only want to concatenate when column B contains TRUE, the formula would be:
="""" & SQLbuilder(B2:B4,TRUE,A2:A4,""", """,FALSE) & """"

Brad

Function SQLbuilder(vTestArray As Variant, vMatch As Variant, vReturnArray As Variant, sSeparator As String, Optional bCaseSensitive As Boolean = False) As String
'Builds a concatentated string of elements from vReturnArray that correspond to cases where vTestArray elements match vMatch
'Elements in the concatenation are separated by sSeparator
'If bCaseSensitive is true, then the match is case sensitive
Dim i As Long
Dim v As Variant
Dim s As String
For Each v In vTestArray
    i = i + 1
    If bCaseSensitive Then
        If v = vMatch Then s = s & sSeparator & vReturnArray(i)
    ElseIf UCase(v) = UCase(vMatch) Then
        s = s & sSeparator & vReturnArray(i)
    End If
Next
If s <> "" Then SQLbuilder = Mid(s, Len(sSeparator) + 1)
End Function

Open in new window

jhoekman

ASKER
HA!  SQL... you overestimate my abilities as a lowly marketer!  :)

Thanks for the above and beyond help, though, Brad.  You da man!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck