How to change composed keywords separated by comma into a cell?

lucato

New Member
Joined
Feb 5, 2012
Messages
3
Hi folks, nice to meet you all.

Lets suppose I have the cell A1 with 100 words or more separated by comma, but the words can be composed word or double words such as "jump up", "Old age","sunny day", or more "holding a face", but I want to find these composed words or double/triple+ words with space that are between commas, and put them between double-quotes. So, as example let's suppose my cell A1 was as:

[A1] word1, jump up, word3, word4, Old age, word6, Sunny day, holding a face,...word100

Want the result as

[A1] word1, "jump up", word3, word4, "Old age", word6, "Sunny day", "holding a face",...word100

It can be a formula on B1 or a trick by using find&replace.

Thanks in advance.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I don't doubt that there is some clever formula-maker out there who will figure out a formula solution for you, but just cannot see anyway to do it. How about a UDF (user defined function) instead...

Code:
Function MultiQuote(S As String) As String
  Dim X As Long, Parts() As String
  Parts = Split(S, ", ")
  For X = 0 To UBound(Parts)
    Parts(X) = Trim(Parts(X))
    If InStr(Parts(X), " ") Then Parts(X) = """" & Parts(X) & """"
  Next
  MultiQuote = Join(Parts, ", ")
End Function
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the UDF, go back to the worksheet and put this formula in B1...

=MultiQuote(A1)
 
Upvote 0
Wow Rick, thanks for the solution very well explained how to use and a quick reply. I appreciated that.
Worked like a charm.
Once again, thanks a lot and have a nice Sunday.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,293
Members
449,077
Latest member
Rkmenon

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