Speed it up if you can

Lukums

Board Regular
Joined
Nov 23, 2015
Messages
195
Morning guys -

Obviously this is looking at the ENTIRE column range it takes a good 3 minutes to run (eventually works as intended) anything I can do about identifying the LASTROW and selecting that with implying the UCASE to the selected range found?

Code:
Sub addresscaptial()

Dim Cell As Range
Columns("D:F").Select
For Each Cell In Selection.Cells
If Not Cell.HasFormula Then
Cell = UCase(Cell)
End If
Next


Call addresscaptial2


End Sub


Sub addresscaptial2()


Dim Cell As Range
Columns("Q:S").Select
For Each Cell In Selection.Cells
If Not Cell.HasFormula Then
Cell = UCase(Cell)
End If
Next


End Sub

Cheers guys,
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Code:
[color=darkblue]Sub[/color] addresscaptial()
    
    [color=darkblue]Dim[/color] Cell [color=darkblue]As[/color] Range
    
    Application.ScreenUpdating = [color=darkblue]False[/color]
    Application.Calculation = xlCalculationManual
    
    [color=darkblue]For[/color] [color=darkblue]Each[/color] Cell [color=darkblue]In[/color] Range("D:F,Q:S").SpecialCells(xlCellTypeConstants)
        Cell = UCase(Cell)
    [color=darkblue]Next[/color]
    
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = [color=darkblue]True[/color]
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
tweaking that a bit, to remove looping cell-by-cell
Code:
Sub addresscapital()
    
    Dim rngCells As Excel.Range
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    
    On Error Resume Next 'to handle no special cells constants found
    For Each rngCells In Range("D:F,Q:S").SpecialCells(xlCellTypeConstants).Areas
        rngCells.Value2 = Application.Evaluate("Upper(" & rngCells.Address & ")")
    Next rngCells
    
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Alternatively, format the columns with a capitals font (e.g. Arial Caps), then no VBA required.
Note: this will capitalise all text including the results of formulas.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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