ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   lowercase to uppercase (https://www.excelbanter.com/excel-programming/389148-lowercase-uppercase.html)

Pekka

lowercase to uppercase
 
Hi
How could I change (VBA code) every lowercase letter in a certain range into
a uppercase letter ?

robotman

lowercase to uppercase
 
There may be a trick that someone else can suggest, but here's a quick
sub to do it.

You can replace "Selection" (i.e. the currently highlighted cells)
with a specific range if you want:

Sub Foo

For Every c in Selection
c.Value = UCase(c.Value)
Next

End Sub

___

John


Gary''s Student

lowercase to uppercase
 
Sub caps_it()
For Each r In Selection
If Not IsEmpty(r) Then
r.Value = UCase(r.Value)
End If
Next
End Sub

--
Gary''s Student - gsnu200720


"Pekka" wrote:

Hi
How could I change (VBA code) every lowercase letter in a certain range into
a uppercase letter ?


Ron de Bruin

lowercase to uppercase
 
Be careful with the two other suggestions
Both will convert formulas in the range to values

A better way is to use SpecialCells

See this two webpages

http://www.mvps.org/dmcritchie/excel/proper.htm
Or
http://www.cpearson.com/excel/case.htm


Here are some Macro's for changing text cells in the selection

Sub Uppercase_macro()
Dim selectie As Range
Dim cel As Range
On Error Resume Next
Set selectie = Range(ActiveCell.Address & "," & Selection.Address) _
.SpecialCells(xlCellTypeConstants, xlTextValues)
If selectie Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each cel In selectie
cel.Value = UCase(cel.Value)
Next cel
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub


Sub Lowercase_macro()
Dim selectie As Range
Dim cel As Range
On Error Resume Next
Set selectie = Range(ActiveCell.Address & "," & Selection.Address) _
.SpecialCells(xlCellTypeConstants, xlTextValues)
If selectie Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each cel In selectie
cel.Value = LCase(cel.Value)
Next cel
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub


Sub Propercase_macro()
Dim selectie As Range
Dim cel As Range
On Error Resume Next
Set selectie = Range(ActiveCell.Address & "," & Selection.Address) _
.SpecialCells(xlCellTypeConstants, xlTextValues)
If selectie Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each cel In selectie
cel.Value = StrConv(cel.Value, vbProperCase)
Next cel
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Pekka" wrote in message ...
Hi
How could I change (VBA code) every lowercase letter in a certain range into
a uppercase letter ?



All times are GMT +1. The time now is 05:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com