Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. 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, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Determining an ANSI Value in a Macro.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
You can, within a macro, save a workbook in several different file formats that are understood by Excel. However, you may ...Discover More
Excel allows you to easily paste graphics into a worksheet. Once added, you may want to quickly process the graphics by ...Discover More
Ever wonder what the macro-oriented equivalent of pressing Ctrl+End is? Here's the code and some caveats on using it.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.