How can I Capitalize each word and remove all special characters and then combine all words in Excel?

asifakhtar

New Member
Joined
Oct 13, 2009
Messages
13
Office Version
  1. 365
I have an Excel sheet with 500 values in column A. I am looking for a formula to Capitalize each word and remove all special characters and then combine all words.
Text in Column A: Vision, mission, values/text and approach
Desired Output: VisionMissionValuestTextAndApproach
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You could try something like this:
Book3
AB
1
2Vision, mission, values/text and approachVisionMissionValuesTextAndApproach
3Vision-mission & 7% ideas, lucky things: other stuffVisionMission7IdeasLuckyThingsOtherStuff
Sheet1
Cell Formulas
RangeFormula
B2:B3B2=SlugifyMod(SUBSTITUTE(PROPER(A2)," ",""),1)

This uses a modified version of the Slugify LAMBDA function:
...modified to permit capital letters (and the original version already allows for numbers and lower case letter), and then I eliminated the feature that inserts hyphens between words. The input to the function is preconditioned by coverting it to PROPER case and then deleting spaces. To run it, copy the LAMBDA function and go to Formula > Name Manager > New...then paste the code in the "Refers to" block and name the function SlugifyMod...and then save and exit. On your worksheet, the function is then called as shown in the example above. Copy the entire block of code and simply paste it into the "Refers to" field on the Name Manager.
Excel Formula:
=LAMBDA(reference,ndx,
      IF(ndx > LEN(reference),
          SUBSTITUTE(reference, "--", ""),
          SlugifyMod(
              LET(
                     character, MID(reference, ndx, 1),
                     charcode, CODE(character),
                     LEFT(reference, ndx - 1) &
                          IF(OR(AND(charcode > 96, charcode < 123), AND(charcode > 47, charcode < 58), AND(charcode > 64, charcode < 91)), character, "") &
                               RIGHT(reference, LEN(reference) - ndx)
              ),
              ndx + 1
          )
      )
  )
 
Upvote 0
Solution
An option using VBA.

Book1
Q
1Vision, mission, values/text and approach
2VisionMissionValuesTextAndApproach
Sheet1
Cell Formulas
RangeFormula
Q2Q2=oa(Q1)


VBA Code:
Function OA(s As String)
With CreateObject("VBScript.RegExp")
    .Pattern = "[a-zA-Z]+"
    .Global = True
    For Each m In .Execute(s)
        OA = OA & StrConv(m.Value, vbProperCase)
    Next m
End With
End Function
 
Upvote 0
Wonderful Lambda...
This formula combines all the words in column A into one single big string, in case this was the requirement:
Excel Formula:
=LET(BareUnit,TEXTJOIN("",TRUE,PROPER(A:A)),Splitted,MID(BareUnit,ROW(INDIRECT("1:"&LEN(BareUnit))),1),ChrSpl,CODE(Splitted),TEXTJOIN("",TRUE,FILTER(Splitted,((ChrSpl>64)*(ChrSpl<91))+(ChrSpl>96)*(ChrSpl<123))))
 
Upvote 0
I like the other offerings from Anthony and @lrobbo314. Here is a version of Anthony's, modified: 1) to operate only on the cell in column A in the same row, and 2) to include numerals. I'm not sure if the OP wants numbers removed from the strings...if numbers are to be removed, then this gets deleted from the LET function: +(ChrSpl>47)*(ChrSpl<58)
MrExcel_20220505B.xlsx
AB
9123Golf, 5%Hotel: and other things123Golf5HotelAndOtherThings
Sheet1
Cell Formulas
RangeFormula
B9B9=LET(BareUnit,TEXTJOIN("",TRUE,PROPER($A9)),Splitted,MID(BareUnit,ROW(INDIRECT("1:"&LEN(BareUnit))),1),ChrSpl,CODE(Splitted),TEXTJOIN("",TRUE,FILTER(Splitted,(ChrSpl>64)*(ChrSpl<91)+(ChrSpl>96)*(ChrSpl<123)+(ChrSpl>47)*(ChrSpl<58))))
 
Upvote 0
A slightly shorter formula without volatile functions
Excel Formula:
=LET(BareUnit,CONCAT(PROPER($A9)),Splitted,MID(BareUnit,SEQUENCE(LEN(BareUnit)),1),ChrSpl,CODE(Splitted),CONCAT(FILTER(Splitted,(ChrSpl>64)*(ChrSpl<91)+(ChrSpl>96)*(ChrSpl<123)+(ChrSpl>47)*(ChrSpl<58))))
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

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