30 Advanced Excel Tips for 2026

Excel Champs / VBA / Top VBA Functions / VBA VAL Function (Syntax + Example)
By Puneet Gogia (Microsoft MVP)

VBA VAL Function (Syntax + Example)

30+ Advanced Excel Tips for 2026

No spam. Only Excel Stuff. God Promise. 😊

The VBA VAL function is listed under the data type conversion category of VBA functions. When you use it in a VBA code, it converts a string into a number. In simple words, it takes a number that is stored as a string and returns it as a number.

Syntax

Val(String)

Arguments

  • String: A string that you want to convert into a number.

Example

To practically understand how to use the VBA VAL function, you need to go through the below example where we have written a vba code by using it:

example-vba-val-function
Sub example_VAL()
Range("B1").Value = Val(Range("A1"))
Range("B2").Value = Val(Range("A2"))    
End Sub

In the above code, we have used VAL to get the numeric value from cells A1 and A2:

  1. In cell A1 we have the value starting with a number and it has extracted that value in cell B1.
  2. But in cell A2, the value is starting with a character that can’t be recognized as a number so it has ignored all the characters after that.

Notes

  • It stops reading the string at the first character it can’t recognize as a number.
  • It recognizes a period (.) as a valid decimal separator.
  • It recognizes symbols and characters as part of numeric values.
Puneet Gogia

Written by

Puneet Gogia

Microsoft MVP — Excel · Founder, Excel Champs

Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.

3M+ readers helped
1,000+ tutorials written
Since 2015 teaching Excel