Excel writing macros new buttons Quick Change case

Source: Internet
Author: User
Tags lowercase

As you often know with friends in Word, you can easily change English characters ' uppercase ', ' lowercase ', ' first-letter ' and ' first-letter caps ' in Word (Figure 1).

Computer Tutorials

However, these features Excel do not have, if you want to use these features in Excel, you must manually modify or use complex formulas for conversion. In fact, we can write related macros to solve this problem once and for all.

First draw four command buttons to change the text on the button to "all caps", "all lowercase", "uppercase" and "uppercase". Then write the corresponding macro code for each button individually.

For example, "All Caps" button, enter the code:

Code fragment:

Sub All caps ()

Dim ITarget as Range

Set ITarget = Selection

For each ran in ITarget

' Convert cell contents to uppercase

Ran.value = UCase (RAN)

Next

End Sub

Right-click the All Lowercase button and enter the code:

Sub all lowercase ()

Dim ITarget as Range

Set ITarget = Selection

For each ran in ITarget

' Converts cell contents to lowercase

Ran.value = LCase (RAN)

Next

End Sub

The button is ready to use when you have completed the above operation. Select the target cell range and click the corresponding conversion button, and the selected English character is immediately converted to the size we want (Figure 2).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.