Microsoft Office Tutorials and References
In Depth Information
Changing the Case of Text
Tip: In the 'Change the following variables' section, change the name of the Table of Contents
sheet to whatever is required, such as “Index”, “Dashboard”, or “Home”.
Changing the Case of Text
This procedure emulates Microsoft Word's functionality to change the case of
text by looping between UPPERCASE, lowercase, Title Case and Sentence
Example file:
Scenario: Excel lacks the functionality that exists in
Microsoft Word to quickly change the case of text. This
macro overcomes that by applying the same principle
existing in Word. Simply select the cells that should change,
run the macro, and it loops between upper case (SAMPLE
CASE), lower case (sample case), title case (Sample Case)
and sentence case (Sample case).
View the Appendix to learn how to store this procedure
in a Standard module.
Option Explicit¶
' * * * * *¶
Sub ChangeCase()¶
'Variable declarations¶
Dim Rng As Range¶
Dim Cll As Range¶
Dim Conversion As Long¶
'To choose between¶
'Sentence case¶
'Title Case¶
'Get the strings within the selection¶
With ActiveWindow.RangeSelection¶
'Only one cell selected¶
If .Count = 1 Then¶
'Is it a text string?¶
If Application.IsText(.Item(1)) Then¶
'If it doesn't have a formula, use it¶
If Not .HasFormula Then Set Rng = .Item(1)¶
Search JabSto ::

Custom Search