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 create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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,216,215
Messages
6,129,560
Members
449,516
Latest member
lukaderanged

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