proper case entire sheet except a few columns

borgatarat

New Member
Joined
May 22, 2014
Messages
9
I use:

Sub ConvertToProper() Dim ws As Object Dim LCell As Range 'Turn off screen updating to increase performance Application.ScreenUpdating = False Application.Calculation = xlCalculationManual 'Move through each sheet in your spreadsheet For Each ws In ActiveWorkbook.Sheets On Error Resume Next ws.Activate 'Convert all constants and text values to proper case For Each LCell In Cells.SpecialCells(xlConstants, xlTextValues) LCell.Formula = StrConv(LCell.Formula, vbProperCase) Next Next ws 'Turn screen updating back on Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = TrueEnd Subfor proper case. How do I add to not apply proper case to certain rows? (B:C & F:I) Thank You!</pre>
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try this (your code but with an INTERSECT)
Code:
Sub ConvertToProper()
Dim ws As Object
Dim LCell As Range 'Turn off screen updating to increase performance
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual 'Move through each sheet in your spreadsheet
For Each ws In ActiveWorkbook.Sheets
    On Error Resume Next
    ws.Activate 'Convert all constants and text values to proper case
    For Each LCell In Intersect(Cells.SpecialCells(xlConstants, xlTextValues), _
        Range("B:C,F:I"))
    LCell.Formula = StrConv(LCell.Formula, vbProperCase)
    Next
    
Next ws 'Turn screen updating back on
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 
Upvote 0
It was bugging me that the macro activated the worksheets, so I got rid of it. It seems to be a little cleaner:
Code:
Sub ConvertToProper()
Dim ws As Object
Dim LCell As Range 'Turn off screen updating to increase performance
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual 'Move through each sheet in your spreadsheet
For Each ws In ActiveWorkbook.Sheets
    On Error Resume Next
    For Each LCell In Intersect(ws.Cells.SpecialCells(xlConstants, xlTextValues), _
        ws.Range("B:C,F:I")) 'added ws in this statement to fully qualify which ranges are being called
    LCell.Formula = StrConv(LCell.Formula, vbProperCase)
    Next
Next ws 'Turn screen updating back on
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

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