DanG
Registered User.
- Local time
- Today, 01:24
- Joined
- Nov 4, 2004
- Messages
- 477
I have acquired this macro and on a small (>1000 rows?) scale works great.
However, I have 43,000 rows X 10 columns or so and that's where things get ugly, I have not been patient enough to see how long it would take.
I am new to VBA, but went through the basics to check if it had calculating & screenupdating set (and it does). Is there a better way to do this or any adjustments that can be made to make it faster?
Thank you
However, I have 43,000 rows X 10 columns or so and that's where things get ugly, I have not been patient enough to see how long it would take.
I am new to VBA, but went through the basics to check if it had calculating & screenupdating set (and it does). Is there a better way to do this or any adjustments that can be made to make it faster?
Code:
Sub FixProper()
Dim LCell As Range
'Turn off screen updating to increase performance
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'Convert all constants and text values to proper case
For Each LCell In Cells.SpecialCells(xlConstants, xlTextValues)
LCell.Formula = StrConv(LCell.Formula, vbProperCase)
Next
For Each LCell In Cells.SpecialCells(xlConstants, xlTextValues)
'--- this is where you would code generalized changes for lastname
'--- applied to names beginning in position 1 of cell
If Left(LCell.Value, 2) = "Mc" Then LCell.Value = _
"Mc" & UCase(Mid(LCell.Value, 3, 1)) & Mid(LCell.Value, 4, 99)
If Left(LCell.Value, 3) = "Mac" _
And Left(LCell.Value, 4) <> "Mack " Then LCell.Value = _
"Mac" & UCase(Mid(LCell.Value, 4, 1)) & Mid(LCell.Value, 5, 99)
'-- do not change Mack Mackey Mackney or any Mack...
If Left(LCell.Value, 2) = "O'" Then LCell.Value = _
"O'" & UCase(Mid(LCell.Value, 3, 1)) & Mid(LCell.Value, 4, 99)
If Left(LCell.Value, 6) = "Po Box" Then LCell.Value = _
"P.O." & Mid(LCell.Value, 3, 99)
If Left(LCell.Value, 4) = "P.o." Then LCell.Value = _
"P.O." & Mid(LCell.Value, 5, 99)
If Left(LCell.Value, 5) = "P.O.b" Then LCell.Value = _
"P.O. " & Mid(LCell.Value, 5, 99)
Next
MsgBox "Please double check for potential errors." & vbCr & "This does not guarantee accuracy for people's names.", vbExclamation, "Reminder"
'Turn screen updating back on
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Thank you