Losing Formatting after Maco Runs

jeran042

New Member
Joined
Jun 9, 2016
Messages
23
I have a simple macro that trims and changes the case of a cell from lower to UPPER, however when I run this macro and the cell is inside of a table, it seems to remove the table. The values remain, but it is converted back to just a range. Here is what my code looks like. Is there any way to preserve the condition and just change the Case?

Code:
Sub Trim_And_UPPER()  
ActiveSheet.UsedRange = Evaluate(Replace("IF(@="""","""",UPPER(TRIM(@)))", "@", ActiveSheet.UsedRange.Address))
End Sub

Much appreciated!
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hello,

try this

Code:
Sub Capital_letters()
    
    Application.ScreenUpdating = False

    Dim cell As Range
    ' here set your range
    For Each cell In Range("C2:D2")
        If Len(cell) > 0 Then cell = UCase(cell)
    Next cell
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
That is where I was headed, I came up with:

Code:
Sub MyUpperCase()    
    Application.ScreenUpdating = False


    Dim cell As Range
    For Each cell In Range("$A$1:" & Range("$A$1").SpecialCells(xlLastCell).Address)
        If Len(cell) > 0 Then cell = Trim(UCase(cell))
    Next cell
    
    Application.ScreenUpdating = True
    
End Sub

Thank you all for your help!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,402
Messages
6,124,708
Members
449,182
Latest member
mrlanc20

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