Ucase to excel via vba (1 Viewer)

CosmaL

Registered User.
Local time
Tomorrow, 01:06
Joined
Jan 14, 2010
Messages
92
Dear friends,

any idea how to use ucase in vba and make an excel column data upppercase?

I've used the following commands under with, but i always get errors.

Ucase.columns("A:A")
.columns.Ucase("A:A")

I think its syntax error returning by excel because i don't get any compile errors.

Thanks in advance!
 

Isaac

Lifelong Learner
Local time
Today, 15:06
Joined
Mar 14, 2017
Messages
8,777
In addition to the method pointed out in post 2, if the only thing you care about is getting your data to look uppercase, and you don't care all that much about the font, then you could avoid the looping method and simply execute a line of code to change the font of an entire column to Copperplate Gothic, Engravers, Felix Tilting, or Stencil. These fonts have no lowercase letters.

This would be more efficient/faster than looping.

Code:
ThisWorkbook.Worksheets("Sheet1").Range("A:A").Font.Name = "Copperplate Gothic Bold"

Unfortunately, this method does not really change the case: If another app reads the data from Excel, it gets read as its original case.

Another method which may be faster than the looping through every range, is to populate and manipulate an array.

Code would be like:
Code:
Sub test2()
Dim ws As Worksheet, arr() As Variant, rng As Range, lastrow As Long, x As Long
'adjust below line to suit *****************
Set ws = ThisWorkbook.Worksheets("Sheet1")
'use whatever column ALWAYS has data in it (doesn't have to be A), below**********
lastrow = ws.Range("A" & ws.Rows.Count).End(-4162).Row
'in below line, reference whatever column you want to convert to upper case **********
Set rng = ws.Range("A1:A" & lastrow)
arr = rng.Value
For x = 1 To UBound(arr)
    arr(x, 1) = UCase(arr(x, 1))
Next x

rng.Value = arr

End Sub
 

Attachments

  • Testing 20200715.zip
    16 KB · Views: 76

Users who are viewing this thread

Top Bottom