Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Determining an ANSI Value in a Macro.
by Allen Wyatt
(last updated May 7, 2022)
When creating a macro, you can use the Asc function to determine the ANSI value of the first letter of a string. In early versions of BASIC, Asc returned the ASCII value, but Excel uses only ANSI values. The function uses the following format:
x = Asc(y)
where x is the variable that the ANSI value should be assigned to, and y is the string to be analyzed. The way in which the Asc function works is very similar to the CODE worksheet function.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2527) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Determining an ANSI Value in a Macro.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
Using macros to step through each cell in a selection is a common occurrence. What if that selected range is made up of ...Discover More
Want to run a macro in Excel, but not sure if doing so will tie up your computer? Here's how macro processing really happens.Discover More
As your macro is processing information, there will doubtless be times that it will need to compare information in ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.