Add a sentence case with numbers

Manolocs

Active Member
Joined
Mar 28, 2008
Messages
340
Hello, I am using this formula to modify all text of a column to sentence case, but I have some cells that the text starts with numbers.
Is there a way to make the first Letter after the number in Upper Case?
Thank you in advance.....

=UPPER(LEFT(B1,1))&LOWER(RIGHT(B1,LEN(B1)-1))
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
please copy the following code to a module
Code:
' First letter Uppercase, all following lowercase
' ignore digits at the beginning

   Dim textLength As Long
   Dim pos        As Long
   Dim result     As String
   
   textLength = Len(text): result = ""
   
   pos = 1
   While pos <= textLength _
     And ((Mid(text, pos, 1) >= "0" And Mid(text, pos, 1) <= "9") _
               Or Mid(text, pos, 1) = " ")
     
      pos = pos + 1
   Wend
   
   If pos > textLength Then
      result = text
      
   Else
      result = Left(text, pos - 1) + UCase(Mid(text, pos, 1))

      If pos < textLength Then
         result = result + LCase(Right(text, textLength - pos))
      End If
   End If
   
   properCase = result
End Function

and then enter the formula
Code:
=properCase(cell to modify)
in every cel you need
 
Upvote 0
I cheated in that I raised a post on here to find out why trailing spaces disappeared - they don't if you keep them in code rather than assigning to a cell in the spreadsheet - also I had in my macro something like cells(1,1)=cells(1,2)&cells(1,3) - this would not compile UNTIL I inserted a space either side of the &
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,275
Members
452,902
Latest member
Knuddeluff

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