XL7: Sample Macro to Edit AutoCorrect List

Last reviewed: September 2, 1997
Article ID: Q142144
The information in this article applies to:
  • Microsoft Excel for Windows 95, version 7.0

SUMMARY

The following examples contain Visual Basic for Applications macros that you can use to add items to and remove items from the Microsoft Excel AutoCorrect list.

With AutoCorrect, changes are made to existing text only when a cell is activated. In addition, the AutoCorrect feature is case sensitive. That is, if you type the original word in capital letters, the replacement will be entered in capital letters as well.

MORE INFORMATION

Microsoft provides examples of Visual Basic for applications procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.

To add an item to the AutoCorrect list

  1. In a new module sheet, enter the following code:

          Sub Add_Item()
    
             'The following macro code assigns "Msft" to replace any new
             'occurrence of the word "Microsoft".
             Application.AutoCorrect.AddReplacement "Microsoft", "msft"
    
          End Sub
    
    

  2. Switch to a worksheet, and click Macro on the Tools menu. Run the Add_Item macro.

  3. To verify that the item was added to the list, click AutoCorrect on the Tools menu and scroll to the bottom of the window.

  4. To test the AutoCorrect entry, type "Microsoft" (without the quotation marks) in any cell on your worksheet, and press ENTER.

The word "Microsoft" in the cell should automatically be changed to "Msft."

To remove an item from the AutoCorrect list

  1. In a module sheet, enter the following code:

          Sub Remove_Item()
    
             'The following macro code removes the replacement
             'item for "Microsoft".
             Application.AutoCorrect.DeleteReplacement "Microsoft"
    
          End Sub
    
    

  2. Click Macro on the Tools menu, and run the Remove_Item macro.

  3. To verify that the item was removed from the list, click AutoCorrect on the Tools menu, and scroll to the bottom of the window.

REFERENCES

For more information about creating macros that run automatically in Microsoft Excel version 7.0, click Answer Wizard on the Help menu and type:

   How do I edit the AutoCorrect list?


Additional query words: 7.00
Keywords : kbcode kbprg PgmHowTo kbhowto
Version : 7.0
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.