Dimitris254
Board Regular
- Joined
- Apr 25, 2016
- Messages
- 139
Sub Macro1()
'
' Macro1 Macro
'
'
Columns("B:B").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=NOT(EXACT(PROPER(B1),B1))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Sub test()
Dim newValue As Variant
Dim i As Long
With Sheet1.Range("B:B")
With Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp))
newValue = .Value
For i = 1 To .Rows.Count
newValue(i, 1) = UCase(Left(newValue(i, 1), 1)) & Mid(newValue(i, 1), 2)
Next i
.Value = newValue
End With
End With
End Sub
Why not let the macro simply correct them for you? Assuming your names are in Column A starting on Row 2 (Row 1 is an assumed header)...The macro would simply highlight the cell that the last name starts with lower letter. Then i will correct it to capital manually.
Sub FixNameCasing()
Dim Addr As String
Addr = "A2:A" & Cells(Rows.Count, "A").End(xlUp).Row
Range(Addr) = Evaluate("IF(" & Addr & "="""","""",PROPER(" & Addr & "))")
End Sub
Sub t()
Dim c As Range
With ActiveSheet
For Each c In .Range("B2", .Cells(Rows.Count, 2).End(xlUp))
txt = StrConv(c.Text, vbProperCase)
c.Value = txt
Next
End With
End Sub