Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Determining an ANSI Value in a Macro.
by Allen Wyatt
(last updated January 30, 2017)
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 (9202) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Determining an ANSI Value in a Macro.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
Need to know the address of the cell that is currently selected? The function and macro highlighted in this tip will come ...Discover More
Macros are great for working with strings, and one of the most commonly used string functions is Len. This tip explains ...Discover More
When developing a macro, you may want to display on the status bar what the macro is doing. Here's how to use this ...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 ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.