ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Capitalize input (https://www.excelbanter.com/excel-programming/330598-capitalize-input.html)

Nalla

Capitalize input
 
Is it possable to capitalize the first letter of an users input as it is
entered into text box that is on a combo box, by useing code
thanks in advance




Nalla

Capitalize input
 

"Nalla" wrote in message
...
Is it possable to capitalize the first letter of an users input as it is
entered into text box that is on a combo box, by useing code
thanks in advance


SoOORY Mean NOT Userform not combobox




Nigel

Capitalize input
 
There are no proper case commands in Excel (unlike Word). But you could
convert the value using the following construct

x = UCase(Mid(x, 1, 1)) & Mid(x, 2)

where x is the string to act upon.

To apply this to a textbox, use the change event

Private Sub TextBox1_Change()
TextBox1.Value = UCase(Mid(TextBox1.Value, 1, 1)) & Mid(TextBox1.Value, 2)
End Sub

--
Cheers
Nigel



"Nalla" wrote in message
...

"Nalla" wrote in message
...
Is it possable to capitalize the first letter of an users input as it is
entered into text box that is on a combo box, by useing code
thanks in advance


SoOORY Mean NOT Userform not combobox






Greg Wilson

Capitalize input
 
If you mean captialize first letter of input into text box on userform then
try:

Private Sub TextBox1_Change()
With TextBox1
If Len(.Text) = 1 Then .Text = UCase(.Text)
End With
End Sub

Regards,
Greg

"Nalla" wrote:

Is it possable to capitalize the first letter of an users input as it is
entered into text box that is on a combo box, by useing code
thanks in advance





Dick Kusleika[_4_]

Capitalize input
 
Nalla wrote:
Is it possable to capitalize the first letter of an users input as it
is entered into text box that is on a combo box, by useing code
thanks in advance


Another way is to change the text after the user is done typing, like

Private Sub TextBox1_AfterUpdate()

Me.TextBox1.Text = StrConv(Me.TextBox1.Text, vbProperCase)

End Sub

This will change the text to proper case, rather than just capitalizing the
first letter. You may prefer this method if you want to prevent the user
from typing in all caps.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com




All times are GMT +1. The time now is 04:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com