Mastodon Mastodon
Excel Tutorials

How to Use a Formula to Convert Text to Sentence Case in Excel?

Excel Formula & VBA Code to Convert Text Strings into Sentence Case Strings!

In Excel, you can easily convert the text string into Sentence Case and it will helps you to read and engageable. While Excel doesn’t have a built-in “sentence case” function, you can achieve this formatting using a custom formula. In this tutorial, I will explain you the multiple methods to convert a text string into a sentence case format in Excel using Formula and VBA codes.

If you want to convert a text string into a valid Capitalized Case and then you can use the Excel PROPER function. The Excel PROPER Function simply converts the text strings into a 1st letter capitalized strings (Each 1st letter of a word will be capitalized in a sentence).

Method 1: Using Formula to Convert Text into Sentence Case:

The below formula converts any text, whether it’s in all capital letters or all lowercase, into sentence case.

=UPPER(LEFT(A2,1)) & LOWER(MID(A2,2,LEN(A2)-1))
Formula Converted the input text strings into a Sentence Case Strings
Formula Converted the input text strings into a Sentence Case Strings

Formula Explanation:

  • LEFT(B4,1) – This part of the formula extracts the first character of the text in cell B4.
  • UPPER(LEFT(B4,1)) – This section converts that first character to uppercase.
  • MID(B4,2,LEN(B4)-1) – This formula, extract the second part of the text string.
  • LOWER(MID(B4,2,LEN(B4)-1)) – Which converts the text string into lowercase.
  • & – Simply appends the text strings.
Functions UsedFunction Explanation
LEFTExtracts a specified number of characters from the start (left side) of a text string.
UPPERConverts all letters in a text string to uppercase.
MIDReturns a specific number of characters from a text string, starting at a specified position.
LENReturns the total number of characters in a text string.
LOWERConverts all letters in a text string to lowercase.

That’s it. This is how you can use the formula to convert any text strings into a sentence case text strings.

Method 2: Using VBA Code to Convert Text into Sentence Case Strings

This is the alternative method to do. You might need to use the VBA code to convert any text string into sentence case strings.

  • First, you need to use the keyboard shortcut ALT + F11 to launch the VBA window.
  • Then from the menu bar, you need to choose Insert -> Module.
Choose Module from the Insert Menu
Choose Module from the Insert Menu
  • Now, you need to copy & paste the below vba code to convert all text strings into sentence case strings.
Sub SentenceCase()
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "Sentence Case by Excel24x7.com"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
    xValue = Rng.Value
    xStart = True
    For i = 1 To VBA.Len(xValue)
        ch = Mid(xValue, i, 1)
        Select Case ch
            Case "."
            xStart = True
            Case "?"
            xStart = True
            Case "a" To "z"
            If xStart Then
                ch = UCase(ch)
                xStart = False
            End If
            Case "A" To "Z"
            If xStart Then
                xStart = False
            Else
                ch = LCase(ch)
            End If
        End Select
        Mid(xValue, i, 1) = ch
    Next
    Rng.Value = xValue
Next
End Sub
Paste the VBA code into the module.
Paste the VBA code into the module.
  • Before executing the code, you need choose the cell range that you want to convert into a sentence case strings.
You need to select the Cell Range
You need to select the Cell Range
  • Now, You need to use the Keyboard shortcut F5 to execute the command.
  • The mini popup window will appear on you screen and in that the selected range value pre-entered by default.
Mini Popup window will appear on your screen
Mini Popup window will appear on your screen
  • Once you check the selected range values, click the OK button to convert all the cell values into a Sentence case text strings.
Video tutorial.

That’s it.

Narendhiran Vijayakumar.

Feel free to comment us below, if you have any queries about the above topic and find more interesting excel tutorials on our homepage: Excel24x7.com.

Recently Published Tutorials:

Narendhiran Vijayakumar

Hello~ I’m Narendhiran Vijayakumar, a dedicated web developer with strong skills in both frontend frameworks and backend development with PHP. I enjoy creating websites that are user-friendly & user-interactive. I’ve successfully created and launched several platforms, including Klickaud.org, Forhub.io, and IMGCentury.com.

Find more about Narendhiran!

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button