Forum Discussion

Clint_E_Hill's avatar
Clint_E_Hill
Brass Contributor
Oct 04, 2023
Solved

Beginner VBA - Change Selection in Sample Uppercase Routine

How do you modify the sample code to perform the text case on: A user-selected cell? A user-selected range? The entire worksheet?      Sub Uppercase() ' Loop to cycle through each cell in...
  • OliverScheurich's avatar
    Oct 04, 2023

    Clint_E_Hill 

    Sub Uppercase_selection()
    Dim rng, x As Range
    Set rng = Selection
       ' Loop to cycle through each cell in the specified range.
       For Each x In rng
       ' Change the text in the range to uppercase letters.
          x.Value = UCase(x.Value)
       Next
    End Sub

    With this code you can either select a cell or a range. Then run the code to change the selected cell or range to uppercase. I wouldn't run this code for the entire worksheet (17,178 billion cells) since it would run forever.

Resources