Excel VBA ASC() Function – Get ASCII Value of Character

The Microsoft Excel ASC(VBA) function returns the ASCII value of a character or the first character in a string passed as arguments.

ASC(VBA) function: Syntax

  Asc( string )

ASC(VBA) function: Parameters or Arguments

The syntax of ASC(VBA) function has just one argument and it is required.

  • string: If string consists of more than one character, ASC(VBA) function returns the ASCII value of the first character in the string.

ASC(VBA) function: Types

The ASC(VBA) function can’t be used as a worksheet function. It can be only used in VBA Subprocedures. So, it is a VBA function.

To find the ASCII value of a character or a text in an Excel worksheet, you can use the CODE() function.

ASC(VBA) function: Example

Asc (“W”) Result: would return 87
Asc (“Wednesday”) Result: would return 87
Asc (“x”) Result: would return 120

For example:

Dim ASCIIResult As Integer
ASCIIResult = Asc ("W")

In this example, the variable ASCIIResult will contain the value 87.

Happy Excelling ☕


Further Readings

Kawser

Hello! Welcome to my Excel blog! It took me some time to be a fan of Excel. But now I am a die-hard fan of MS Excel. I learn new ways of doing things with Excel and share them here. Not only how-to guide on Excel, but you will get also topics on Finance, Statistics, Data Analysis, and BI. Stay tuned! You can checkout my courses at Udemy: https://www.udemy.com/user/exceldemy/

We will be happy to hear your thoughts

Leave a reply

ExcelDemy
Logo