I need to capitalize every cell in excel with first letter as capital?any easy way to accomplish it?
Sim, use essa macro. Lembre-se de fazer um backup do arquivo primeiro!
Sub uppercase()
For Each cell In Application.ActiveSheet.UsedRange
If (cell.Value <> "") Then
cell.Value = UCase(cell.Value) ' this will make the entire cell upper case
End If
Next
End Sub
Para fazer a primeira letra de cada célula maiúscula você usaria
cell.Value = UCase(Left(cell.Value, 1)) & Right(cell.Value, Len(cell.Value) - 1) 'This will make the first word in the cell upper case
Para criar um título, use
Sub titleCase()
For Each cell In Application.ActiveSheet.UsedRange
If (cell.Value <> "") Then
cell.Value = TitleCase(cell.Value) ' this will make the entire cell upper case
End If
Next
End Sub
Function TitleCase(s) As String
a = Split(s, " ")
For i = 0 To UBound(a)
If (Trim(a(i)) <> "") Then
TitleCase = TitleCase & UCase(Left(a(i), 1)) & Right(a(i), Len(a(i)) - 1) & " "
End If
Next
TitleCase = Trim(TitleCase)
End Function