Capitalizing 1st letter of every word in a column


Posted by Matt on December 09, 2000 6:38 PM

I'm submitting an excel form to goto for my search listings and I'm stuck on Capitalizing the 1st letter of every word in a particular column. Each cell contains more than one word, so I need the first letter of each to be capitalized.

Posted by Aladin Akyurek on December 09, 2000 11:52 PM

Matt,

If you want "Title Case" as it's called in MS Word, use (A1 being the first cell that contains word(s)) in B1

=PROPER(A1)

If you want "Sentence Case" as it's called in MS Word, use in B1

=CONCATENATE(UPPER(MID(A1,1,1)),MID(A1,2,LEN(A1)-1))

Aladin

Posted by Ivan Moala on December 10, 2000 12:59 AM

Try this macro which uses the proper command.
The Proper command Capitalizes the first letter in a text string and any other letters in text that follow any character other than a letter. Converts all other letters to lowercase letters.

Sub MakeProper()
Dim TextRgCaseChg As Range
Dim cell

Set TextRgCaseChg = Selection.SpecialCells(xlCellTypeConstants, 2)

For Each cell In TextRgCaseChg.Cells
cell.Value = Application.WorksheetFunction.Proper(cell.Text)
Next
End Sub

Ivan

Posted by Celia on December 10, 2000 3:09 AM


I don't know why but if only one cell is selected, the line that reads "Set TextRgCaseChg = Selection.SpecialCells(xlCellTypeConstants, 2)" seems to assign ALL text cells on the worksheet to the variable.
I use the following macro to convert to Proper case :-

Sub TextProperCase()
Dim rng As Range, cell As Range
Set rng = Intersect(ActiveSheet.UsedRange, Selection)
For Each cell In rng
If cell.HasFormula = False Then
cell.Value = StrConv(cell.Value, vbProperCase)
End If
Next cell
End Sub

Celia




Posted by Ivan Moala on December 10, 2000 3:23 AM


My mistake the macro actually DOES ALL cells
in the active sheet with text and not a column
range as specified :-(

Ivan