If you want to automatically make first letter in Uppercase and rest of the characters in lowercase. No matter what case you are typing-in but it will be automatically done by Copying and Pasting the below Code under KeyPress Event of the Textbox
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("A") To Asc("Z")
If InStr(1, TextBox1.Text, Chr(KeyAscii)) > 0 Or TextBox1.SelStart > 0 Then
KeyAscii = Asc(LCase(Chr((KeyAscii.Value))))
Else
KeyAscii = Asc(UCase(Chr((KeyAscii.Value))))
End If
Case Asc("a") To Asc("z")
If InStr(1, TextBox1.Text, Chr(KeyAscii)) > 0 Or TextBox1.SelStart > 0 Then
KeyAscii = Asc(LCase(Chr((KeyAscii.Value))))
Else
KeyAscii = Asc(UCase(Chr((KeyAscii.Value))))
End If
Case Else
End Select
End Sub
Read This Also:
0 Comments