ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change a range to Uppercase (https://www.excelbanter.com/excel-programming/404085-change-range-uppercase.html)

Roger Converse[_2_]

Change a range to Uppercase
 
Hello,

How would I update a range of cells to all uppercase?

My range is:

r = Range("A17:K" & i)

How could I create a loop or something that would change all cells in that
range to uppercase?

Thank you,
Roger

Nigel[_2_]

Change a range to Uppercase
 
Sub test()
Dim c As Range, r As Range, i As Long

i = 100 ' set for my test only!

Set r = Range("A17:K" & i)
For Each c In r
c.Value = UCase(c.Value)
Next

End Sub


--

Regards,
Nigel




"Roger Converse" wrote in message
...
Hello,

How would I update a range of cells to all uppercase?

My range is:

r = Range("A17:K" & i)

How could I create a loop or something that would change all cells in that
range to uppercase?

Thank you,
Roger



GB

Change a range to Uppercase
 
One way (though not the only one) would be to establish a nested loop of two
variables one for the row and one for the column.

for i= (row start) to (row end)
for j = (column start) to (column end)
cell(i, j).text = Ucase(cell(i, j).text)
next j
next i

(my usage of cell(i, j) may need to be cells(i, j) or range (cells(i, j),
cells(i, j)) or even further activesheet.cells or activesheet.range) but it
at least gives the idea. Sorry that I haven't verified the exact usage of
cell(i, j).text but the function you are looking for is the UCASE() function.
"Roger Converse" wrote:

Hello,

How would I update a range of cells to all uppercase?

My range is:

r = Range("A17:K" & i)

How could I create a loop or something that would change all cells in that
range to uppercase?

Thank you,
Roger


Roger Converse[_2_]

Change a range to Uppercase
 
Works perfectly.

Thanks!
Roger

"Nigel" wrote:

Sub test()
Dim c As Range, r As Range, i As Long

i = 100 ' set for my test only!

Set r = Range("A17:K" & i)
For Each c In r
c.Value = UCase(c.Value)
Next

End Sub


--

Regards,
Nigel




"Roger Converse" wrote in message
...
Hello,

How would I update a range of cells to all uppercase?

My range is:

r = Range("A17:K" & i)

How could I create a loop or something that would change all cells in that
range to uppercase?

Thank you,
Roger




All times are GMT +1. The time now is 11:21 AM.

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