This Excel tutorial explains how to use the Excel VAL function with syntax and examples.
The Microsoft Excel VAL function accepts a string as input and returns the numbers found in that string.
The syntax for the VAL function in Microsoft Excel is:
Val( string )
Note: The VAL function will stop reading the string once it encounters the first non-numeric character. This does not include spaces.
The VAL function can be used in the following versions of Microsoft Excel:
The VAL function can be used in Microsoft Excel as the following type of function:
The VAL function can only be used in VBA code in Microsoft Excel.
Let's look at some Excel VAL function examples and explore how to use the VAL function in Excel VBA code:
Val("10 Main Street") Result: 10 Val("34 10 Main Street") Result: 3410 Val(" 34 10 Main Street") Result: 3410 Val(" 34 - 10 Main Street") Result: 34 Val("075") Result: 75
Dim LNumber As Double LNumber = Val("56.2 tables")
In this example, the variable called LNumber would now contain the value of 56.2.
(scroll to see more)