{"id":1777,"date":"2011-09-22T10:43:54","date_gmt":"2011-09-22T10:43:54","guid":{"rendered":"http:\/\/www.microsofttraining.net\/b\/exceltraining\/?p=230"},"modified":"2023-12-30T23:13:58","modified_gmt":"2023-12-30T23:13:58","slug":"excel-macro-training-to-change-text-to-upper-or-proper-case","status":"publish","type":"post","link":"https:\/\/www.stl-training.co.uk\/b\/excel-macro-training-to-change-text-to-upper-or-proper-case\/","title":{"rendered":"Excel macro training: To change text to upper or proper case"},"content":{"rendered":"<p>On a recent <strong>Excel VBA Intermediate<\/strong> course\u00a0everyone\u00a0thought a macro for converting text to upper or proper case would be\u00a0helpful. It&#8217;s a good one to put into\u00a0your <strong>Personal Macro Workbook<\/strong>\u00a0then\u00a0assign to\u00a0a button on your <strong>Quick Access Toolbar<\/strong>. Here&#8217;s how to do it:<\/p>\n<p>1. Starting with a blank Workbook record a macro called ConvertCase in the Personal Macro Workbook.\u00a0With <strong>Excel 2007<\/strong> or <strong>Excel 2010<\/strong>\u00a0click View, Macros, Record Macro&#8230;<\/p>\n<p>2. Press OK\u00a0\u00a0then straight away click Macros, Stop Recording.<\/p>\n<p>3. Press <strong>Alt+F11<\/strong> to view the <strong>VBA Editor<\/strong> and open the module and code window for the blank ConvertCase macro.<\/p>\n<p>4. Now add the following code:<\/p>\n<p>Sub ConvertCase()<br \/>\n&#8216;Macro to start frmConvertCase<br \/>\nfrmConvertCase.Show<br \/>\nEnd Sub<\/p>\n<p>Sub Uppercase()<br \/>\nFor Each rng In Selection<br \/>\n\u00a0\u00a0\u00a0 rng.Value = UCase(rng.Value)<br \/>\nNext rng<br \/>\nEnd Sub<\/p>\n<p>Sub Propercase()<br \/>\nFor Each rng In Selection<br \/>\n\u00a0\u00a0\u00a0 rng.Value = Application.WorksheetFunction.Proper(rng.Value)<br \/>\nNext rng<br \/>\nEnd Sub<\/p>\n<p>5. Insert a <strong>User Form<\/strong> and name it frmConvertCase using the<strong> Properties<\/strong> window adding a caption &#8216;Convert Case&#8217;.<\/p>\n<p>6. Add two\u00a0<strong>Option buttons<\/strong> and two <strong>Command buttons<\/strong> to your form:<\/p>\n<p>\u00a07. Name the controls Upper,\u00a0Proper, OK and Cancel\u00a0adding captions as shown below.<\/p>\n<p>\u00a0<a href=\"https:\/\/www.stl-training.co.uk\/b\/exceltraining\/files\/2011\/09\/ConvertCasepic.jpg\"><img decoding=\"async\" class=\"aligncenter size-medium wp-image-233\" src=\"https:\/\/www.stl-training.co.uk\/b\/exceltraining\/files\/2011\/09\/ConvertCasepic-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" \/><\/a><\/p>\n<p>\u00a08. Double click the <strong>OK button<\/strong> and add the following code:<\/p>\n<p>Private Sub OK_Click()<br \/>\nDim rng As Range<br \/>\nIf UPPER.Value = True Then<br \/>\nCall uppercase<br \/>\nElseIf Proper.Value = True Then<br \/>\nCall propercase<br \/>\nElse<br \/>\nMsgBox &#8220;Please choose either upper or proper case&#8221;<br \/>\nEnd If<br \/>\nEnd Sub<\/p>\n<p>9. Close the code window\u00a0the double click\u00a0the Cancel button adding the following code:<\/p>\n<p>Private Sub Cancel_Click()<br \/>\nUnload frmConvertCase<br \/>\nEnd Sub<\/p>\n<p>10. Finally close the VBA Editor and customise your Quick Access\u00a0Toolbar.<br \/>\nSelect <strong>More Commands<\/strong>, Choose commands from <strong>Macros<\/strong> and select your ConvertCase macro, <strong>Add<\/strong>,\u00a0OK.<\/p>\n<p>That&#8217;s it. You now have a permenant button to change case of any selected text!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On a recent Excel VBA Intermediate course\u00a0everyone\u00a0thought a macro for converting text to upper or proper case would be\u00a0helpful. It&#8217;s a good one to put into\u00a0your Personal Macro Workbook\u00a0then\u00a0assign to\u00a0a button on your Quick Access Toolbar. Here&#8217;s how to do it: 1. Starting with a blank Workbook record a macro called ConvertCase in the Personal [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[149,224,232,233,415,573],"class_list":["post-1777","post","type-post","status-publish","format-standard","hentry","category-excel-training","tag-dd","tag-excel-training-london","tag-excel-vba-course-london","tag-excel-vba-courses","tag-personal-macro-workbook","tag-vba-macro"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts\/1777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/comments?post=1777"}],"version-history":[{"count":1,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts\/1777\/revisions"}],"predecessor-version":[{"id":6792,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts\/1777\/revisions\/6792"}],"wp:attachment":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/media?parent=1777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/categories?post=1777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/tags?post=1777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}