{"id":12097,"date":"2011-11-26T08:52:44","date_gmt":"2011-11-26T08:52:44","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/?p=826"},"modified":"2011-11-26T08:52:44","modified_gmt":"2011-11-26T08:52:44","slug":"force-input-to-uppercase-lowercase-in-textbox","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2011\/11\/force-input-to-uppercase-lowercase-in-textbox\/","title":{"rendered":"How can I force input to Uppercase or Lowercase in a Textbox"},"content":{"rendered":"

At some point of time you may need user to force to Enter in a particular Case in your Excel Macro Text Box. It could be either in a Lower Case or Upper Case. Unfortunately in VBA Text Box, you don’t have any inbuilt settings to do so. However by writing few lines code under Textbox Change Event<\/strong> , you can achieve this.<\/p>\n

Here in this Article you learn how to achieve all these settings in VBA Textbox.<\/p>\n

This is possible by using 2 functions: 1. StrConv()<\/a> and 2. LCase or UCase<\/strong><\/p>\n

How to force input to Upper case in VBA Textbox:<\/h2>\n

By using StrConv()<\/a> function in VB<\/h2>\n
\nPrivate Sub TextBox1_Change()\nTextBox1.Text = StrConv(TextBox1.Text, vbUpperCase)\nEnd Sub\n<\/code><\/pre>\n

By using “UCase” function in VB<\/h2>\n
\nPrivate Sub TextBox1_Change()\nTextBox1.Text = UCase(TextBox1.Text)\nEnd Sub\n<\/code><\/pre>\n

How to force input to Lower case in VBA Textbox:<\/h2>\n

By using StrConv()<\/a> function in VB<\/h2>\n
\nPrivate Sub TextBox1_Change()\nTextBox1.Text = StrConv(TextBox1.Text, vbLowerCase)\nEnd Sub\n<\/code><\/pre>\n

By using “LCase” function in VB<\/h2>\n
\nPrivate Sub TextBox1_Change()\nTextBox1.Text = LCase(TextBox1.Text)\nEnd Sub\n<\/code><\/pre>\n

Read This Also:<\/strong><\/p>\n