|
Capitalize the First Letter of Every Word in a Cell
This macro will make the text of any selected cell in excel proper case. This means that the first letter of any word in excel will be capitalized. This macro works on any selection of cells in columns, rows, or a combination of the two.
Where to install the macro: Module
Convert Text in Cells to Proper Case - First Letter of Each Word Capitalized
Sub Proper_Case()
'
'This will make the first letter of the text within any selection of 'cells uppercase.
'
For Each x In Selection
x.Value = Application.Proper(x.Value)
Next
End Sub
How to Install the Macro
- Select and copy the text from within the grey box above.
- Open the Microsoft Excel file in which you would like the Macro to function.
- Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.
Or For other ways to get there, Click Here.
For Excel Versions Prior to Excel 2007 Go to Tools > Macros > Visual Basic Editor
For Excel 2007 Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic
- On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.
- If the Macro goes in a Module, Click Here, otherwise continue to Step 8.
- Go to the menu at the top of the window and click Insert > Module
- Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
- Go to Step 8.
- If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.
- Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
- Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
- A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
- Go to Step 8.
- If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.
- Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
- Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
- A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
- Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
- Go to Step 8.
- Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.
- You are now ready to run the macro.
Similar Helpful Excel Resources
Hi,
How do I automatically capitalize the first letter of every word in an excel cell?
Thanks.
Ins
I am preparing a list of addresses, some of which are in all lower case. Is there a way to automatically capitalize the first letter of each word in Excel? Again, I already have the addresses typed out, so it isn't just a matter of having Excel automatically capitalize the first letter of each word as I type them.
And I realize this is an Excel forum, but perhaps there is a way to do this in Word?
I'm trying to put together a userform that has multiple text boxes on it and I'd like to have the form auto capitalize the first letter in each word of the various text boxes. Some of the words in the text boxes will contain numbers, just as a heads up. I've searched and cannot find anything that I can get to work. Below is the code I have started, but I have no idea if it is even in the ballpark. If I can put together a sub that will do all the boxes at once instead of the individual fields that would be great, what I have started was one of the fields. Please help
Code:
Private Sub B1FirstName_Change()
Dim x As Range
'This will make the first letter of the text within any selection of
'cells uppercase.
For Each x In Selection
x.Value = StrConv(x.Value, vbProperCase)
Next x
End Sub
Hi i found this VBA but i need it to change it for more columns not just column 3 ("C") i also need D F G J T W. how can this formula be modified?
Thank you.
Hi,
I have this code that helps me force text to UPPER & lower case and have the one for ProperCase.
What I cant find, is one that will capitalize just the first letter of each sentence.
Is there such a formular? I have set it in the auto correct function, but it still doesn't do it as I type in a cell.
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
On Error Resume Next
' forces text to UPPERCase
If Not Intersect(Target, Range("B4:B153")) Is Nothing Then
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True
End If
' forces text to lowerCase
If Not Intersect(Target, Range("C4:D153")) Is Nothing Then
Application.EnableEvents = False
Target = LCase(Target)
Application.EnableEvents = True
End If
On Error Goto 0
End Sub
If you like these VB formatting tags please consider sponsoring me in support of injured Royal Marines
Hope someone can help.
Tayler
In Excel 2003, I am referencing a text string and would like to return the text string with only the first letter capitalized. The PROPER function does not do this, as it capitalizes the first letter of every word. The formula below does however perform this, but I would like to write it as a User-Defined Function, similar to the Proper function, so it can be applied to multiple different workbooks:
=UPPER(LEFT(A1,1))&LOWER(RIGHT(A1,LEN(A1)-1))
Is it even possible to write a User-Defined Function to complete this seemingly simple task and, if so, how do I do it?
Thanks,
Chris
I've got a bunch of text in column A. Here's a sample:
in cell A1, don't wait too long
in cell A2, i'll look around
And so on.
I want to capitalize each word so that in column B, it looks like:
B1) Don't Wait Too Long
B2) I'll Look Around
===============================
I did a Google search before posting and it seems the PROPER function is the solution here but when I enter =PROPER(A1) I get the following result which is definitely not want I want.
Don'T Wait Too Long
I'Ll Look Around
Obviously the apostrophy is mucking up the works. Is there a way to have Excel ignore the apostrophy when capitalizing words?
Im looking to find the word sample throughout my spreadsheet its, scattered every where, and i need to change sample to Sample,
and idea?
the range is a1:z500
Hi All,
It's my first post here. I've been sitting for nearly a day on Google and in Excel 2007, and have not been able to find a good solution for a problem I'm having.
What I need to do is fairly simple to explain:
I want to have the first letter of every word in a cell to be capitalized, but the rest of each word must remain as is.
Ie: If I have "My AMD CPU still has some pew-pew" in a cell, I want to be able to use a function, let's say:
=CapFix("My AMD CPU still has some pew-pew")
and the output should be:
My AMD CPU Still Has Some Pew-pew
I've tried using:
=PROPER("My AMD CPU still has some pew-pew")
But the output is:
My Amd Cpu Still Has Some Pew-pew
Which is incorrect (capitalization in the rest of the words "AMD" and "CPU" is lost). Does anybody here know what can be done to solve this problem, or have any info about what I can use to solve it? I have not been able to find any built-in Excel function to solve this, nor ASAP Utilities and I can add VBA code and macros, I just don't know how to manipulate the strings correctly or do the loops, etc that I think will be necessary to solve this.
If anyone could help, it would be much appreciated. I've not seen a single site where a similar problem has been posted. Even if you can't give me a full solution, but can point me in any direction that would be useful, I'd be really grateful.
Thanks in advance .
Hi guys,
I have to loop through a range in A, and if the letter "C" or the number "9" appears in the cell anywhere (it won't be a whole cell value) then I need column B to show "C".
I know how to do a whole value loop, but I'm stumped on a 'find X anywhere' search.
Thanks
|
|