Q:

Intrinsic Convert Text to Number - VBA

If I have Text in cells that I want to convert to numbers, I usually write little subs like:
Sub ConvertToNumber()
    With ActiveCell
        .NumberFormat = "General"
        .Value = Trim(.Text)
    End With
End Sub

I recently discovered that I could perform the conversion without any custom coding and without any VBA.   I can do this by selecting Convert to Number from the warning context menu:

My question is how can I get to this functionality from VBA?   Is there any "built-in" Property or Method associated with the Range Object that performs the conversion directly?? 

A:

The class VBA.Conversion contains a host of conversion functions, including CInt() and CDbl() that seem particularly suited to your question:
CBool(expression)
CByte(expression)
CChar(expression)
CDate(expression)
CDbl(expression)
CDec(expression)
CInt(expression)
CLng(expression)
CObj(expression)
CSByte(expression)
CShort(expression)
CSng(expression)
CStr(expression)
CUInt(expression)
CULng(expression)
CUShort(expression)

