31. VBA Tips - Convert Text To Number VBA

Nick's picture

Convert Text To a Number using VBA

 - use: EVALUATE()

Here's a step through demo sub routine:

Sub ConvertTextToNumber()
  ' set 'a' to a piece of text
  a = "123"
  ' display it
  MsgBox a
  ' Is it a number ? No
  MsgBox Application.IsNumber(a)
  ' convert text to number
  a = Evaluate(a)
  ' display it.. NOTE - it looks the same
  MsgBox a
  ' Is it a number ? Yes
  MsgBox Application.IsNumber(a)
End Sub

Download sheet to practise how to Convert Text To a Number using VBA

 

Training video on how to Convert Text To a Number