Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

Excel-VBA : Math Functions – VAL()

Excel-VBA : Math Functions – VAL()

Description: The VAL function in MS excel returns the number found in the input string

NOTE: This function stops reading the string when it finds first non-numeric charater. Blank spaces are not considered as non-numeric character.

Format:

VBA Function : VAL(string)

Arguments:

  • Number
    • Mandatory
    • Type: String
    • String from which the number needs to be extracted.

Cases:

10 Sumit 10
20 Jain 20
10 20 Sumit Jain 1020
44.2 – I m double 44.2
No Number 0

Example:

Function getVAL()
    val1 = "10 Sumit"
    val2 = "20 Jain"
    val3 = "10 20 Sumit Jain"
    val4 = "No Number"
    strResult = "The VAL of String " & val1 & " is " & Val(val1) & vbCrLf
    strResult = strResult & "The VAL of String " & val2 & " is " & Val(val2) & vbCrLf
    strResult = strResult & "The VAL of String " & val3 & " is " & Val(val3) & vbCrLf
    strResult = strResult & "The VAL of String " & val4 & " is " & Val(val4)
    MsgBox strResult
End Function

VAL - VBA

VAL – VBA

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: