textbox values to uppercase

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
Hi all,

Can anyone help.

I would like a vba script that changes the textbox1 value in userform1 to uppercase upon clicking on commanbutton1 (without having to enter the textbox value into a sheet).

I tried the Application.AutoCorrect but it just changed the value to True.

Thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Code:
[/FONT]
[FONT=Courier New]Option Explicit
Private Sub CommandButton1_Click()
Me.TextBox1.Value = UCase(Me.TextBox1.Value)
End Sub
 
Upvote 0
That's great Pedie,

Can it be incorporated into the following so that any textbox tags that have an x it will change them to uppercase.


Code:
For Each Ctrl In Me.Controls
        If Ctrl.Tag = "x" Then
            Select Case TypeName(Ctrl)
                Case "TextBox": Ctrl.Value = ""
                Case "ComboBox": Ctrl.ListIndex = -1
            End Select
        End If
    Next Ctrl
 
Upvote 0
Try this
Code:
[/FONT]
[FONT=Courier New]Private Sub CommandButton1_Click()
Dim Ctrl As Control
For Each Ctrl In Me.Controls
        If Ctrl.Tag = "x" Then
         Ctrl.Value = UCase(Ctrl.Value)
        End If
    Next Ctrl
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,307
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top