Add a stop to a macro when first empty row

Glafond

New Member
Joined
Apr 4, 2022
Messages
2
Platform
  1. Windows
I'm using this macro to change text to Uppercase :

For Each cell In Range("A5:CU304")
cell.Value = UCase(cell.Value)
Next

The macro works well, but it takes time to process every cell from this range. In general, I won't have that many rows with values.
I'ld like ma macro to stop when hitting an empty value in the A column, so it would go faster for few rows files.

How can i change my macro to stop at first empty "A" cell and go to next action (copy to value + save)?

Thanks !
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
try this which should be about 1000 times faster
VBA Code:
Sub test()
alldata = Range("A5:CU304")
For i = 1 To UBound(alldata, 1)
 For j = 1 To UBound(alldata, 2)
  alldata(i, j) = UCase(alldata(i, j))
 Next j
Next i
Range("A5:CU304") = alldata
End Sub
 
Upvote 0
Solution
try this which should be about 1000 times faster
VBA Code:
Sub test()
alldata = Range("A5:CU304")
For i = 1 To UBound(alldata, 1)
 For j = 1 To UBound(alldata, 2)
  alldata(i, j) = UCase(alldata(i, j))
 Next j
Next i
Range("A5:CU304") = alldata
End Sub
It works perfectly :)
Thanks !
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,553
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top